Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-11-29 03:20:26
Exec Total Coverage
Lines: 1021 3926 26.0%
Functions: 78 340 22.9%
Branches: 409 2814 14.5%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 11 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 //#include "zquest.h"
30 #include "init.h"
31 #include "replay.h"
32 #include "cheats.h"
33 #include "base/zc_math.h"
34
35 #ifdef ALLEGRO_DOS
36 #include <unistd.h>
37 #endif
38
39 #include "metadata/metadata.h"
40 #include "zelda.h"
41 #include "tiles.h"
42 #include "base/colors.h"
43 #include "pal.h"
44 #include "base/zsys.h"
45 #include "qst.h"
46 #include "zc_sys.h"
47 #include "play_midi.h"
48 #include "debug.h"
49 #include "jwin.h"
50 #include "base/jwinfsel.h"
51 #include "base/gui.h"
52 #include "midi.h"
53 #include "subscr.h"
54 #include "maps.h"
55 #include "sprite.h"
56 #include "guys.h"
57 #include "hero.h"
58 #include "title.h"
59 #include "particles.h"
60 #include "zconsole.h"
61 #include "ffscript.h"
62 #include "dialog/info.h"
63 #include "dialog/alert.h"
64 #include <fmt/format.h>
65 #include "WindowsScaling.h"
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte disable_direct_updating;
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 byte epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
11 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 // Dialogue largening
171 void large_dialog(DIALOG *d)
172 {
173 large_dialog(d, 1.5);
174 }
175
176 void large_dialog(DIALOG *d, float RESIZE_AMT)
177 {
178 if(!d[0].d1)
179 {
180 d[0].d1 = 1;
181 int32_t oldwidth = d[0].w;
182 int32_t oldheight = d[0].h;
183 int32_t oldx = d[0].x;
184 int32_t oldy = d[0].y;
185 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
186 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
187 d[0].w = int32_t(d[0].w*RESIZE_AMT);
188 d[0].h = int32_t(d[0].h*RESIZE_AMT);
189
190 for(int32_t i=1; d[i].proc !=NULL; i++)
191 {
192 // Place elements horizontally
193 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
194 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
195
196 if(d[i].proc != d_stringloader)
197 {
198 if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].w *= 2;
201 }
202 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
203 }
204
205 // Place elements vertically
206 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
207 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
208
209 // Vertically resize elements
210 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
211 {
212 d[i].h = int32_t((double)d[i].h*1.5);
213 }
214 else if(d[i].proc == jwin_droplist_proc)
215 {
216 d[i].y += int32_t((double)d[i].h*0.25);
217 d[i].h = int32_t((double)d[i].h*1.25);
218 }
219 else if(d[i].proc==d_bitmap_proc)
220 {
221 d[i].h *= 2;
222 }
223 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
224
225 // Fix frames
226 if(d[i].proc == jwin_frame_proc)
227 {
228 d[i].x++;
229 d[i].y++;
230 d[i].w-=4;
231 d[i].h-=4;
232 }
233 }
234 }
235
236 for(int32_t i=1; d[i].proc!=NULL; i++)
237 {
238 if(d[i].proc==jwin_slider_proc)
239 continue;
240
241 // Bigger font
242 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
243
244 if(!d[i].dp2 && bigfontproc)
245 {
246 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
247 d[i].dp2 = lfont_l;
248 }
249 else if(!bigfontproc)
250 {
251 // ((ListData *)d[i].dp)->font = &sfont3;
252 ((ListData *)d[i].dp)->font = &lfont_l;
253 }
254
255 // Make checkboxes work
256 if(d[i].proc == jwin_check_proc)
257 d[i].proc = jwin_checkfont_proc;
258 else if(d[i].proc == jwin_radio_proc)
259 d[i].proc = jwin_radiofont_proc;
260 }
261
262 jwin_center_dialog(d);
263 }
264
265
266 /**********************************/
267 /******** System functions ********/
268 /**********************************/
269
270 static char cfg_sect[] = "zeldadx"; //We need to rename this.
271
272 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
273 {
274 return D_O_K;
275 }
276
277 11 void load_game_configs()
278 {
279 //set_config_file("zc.cfg"); //shift back when done
280 //load the module
281 11 strcpy(moduledata.module_name,get_config_string("ZCMODULE",qst_module_name,"classic.zmod"));
282 11 joystick_index = zc_get_config(cfg_sect,"joystick_index",0);
283 11 js_stick_1_x_stick = zc_get_config(cfg_sect,"js_stick_1_x_stick",0);
284 11 js_stick_1_x_axis = zc_get_config(cfg_sect,"js_stick_1_x_axis",0);
285 11 js_stick_1_x_offset = zc_get_config(cfg_sect,"js_stick_1_x_offset",0) ? 128 : 0;
286 11 js_stick_1_y_stick = zc_get_config(cfg_sect,"js_stick_1_y_stick",0);
287 11 js_stick_1_y_axis = zc_get_config(cfg_sect,"js_stick_1_y_axis",1);
288 11 js_stick_1_y_offset = zc_get_config(cfg_sect,"js_stick_1_y_offset",0) ? 128 : 0;
289 11 js_stick_2_x_stick = zc_get_config(cfg_sect,"js_stick_2_x_stick",1);
290 11 js_stick_2_x_axis = zc_get_config(cfg_sect,"js_stick_2_x_axis",0);
291 11 js_stick_2_x_offset = zc_get_config(cfg_sect,"js_stick_2_x_offset",0) ? 128 : 0;
292 11 js_stick_2_y_stick = zc_get_config(cfg_sect,"js_stick_2_y_stick",1);
293 11 js_stick_2_y_axis = zc_get_config(cfg_sect,"js_stick_2_y_axis",1);
294 11 js_stick_2_y_offset = zc_get_config(cfg_sect,"js_stick_2_y_offset",0) ? 128 : 0;
295 11 analog_movement = (zc_get_config(cfg_sect,"analog_movement",1));
296
297 //cheat modifier keya
298 11 cheat_modifier_keys[0] = zc_get_config(cfg_sect,"key_cheatmod_a1",KEY_LSHIFT);
299 11 cheat_modifier_keys[1] = zc_get_config(cfg_sect,"key_cheatmod_a2",0);
300 11 cheat_modifier_keys[2] = zc_get_config(cfg_sect,"key_cheatmod_b1",KEY_RSHIFT);
301 11 cheat_modifier_keys[3] = zc_get_config(cfg_sect,"key_cheatmod_b2",0);
302
303
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
304 joystick_index = 0;
305
306 11 Akey = zc_get_config(cfg_sect,"key_a",KEY_ALT);
307 11 Bkey = zc_get_config(cfg_sect,"key_b",KEY_ZC_LCONTROL);
308 11 Skey = zc_get_config(cfg_sect,"key_s",KEY_ENTER);
309 11 Lkey = zc_get_config(cfg_sect,"key_l",KEY_Z);
310 11 Rkey = zc_get_config(cfg_sect,"key_r",KEY_X);
311 11 Pkey = zc_get_config(cfg_sect,"key_p",KEY_SPACE);
312 11 Exkey1 = zc_get_config(cfg_sect,"key_ex1",KEY_Q);
313 11 Exkey2 = zc_get_config(cfg_sect,"key_ex2",KEY_W);
314 11 Exkey3 = zc_get_config(cfg_sect,"key_ex3",KEY_A);
315 11 Exkey4 = zc_get_config(cfg_sect,"key_ex4",KEY_S);
316
317 11 DUkey = zc_get_config(cfg_sect,"key_up", KEY_UP);
318 11 DDkey = zc_get_config(cfg_sect,"key_down", KEY_DOWN);
319 11 DLkey = zc_get_config(cfg_sect,"key_left", KEY_LEFT);
320 11 DRkey = zc_get_config(cfg_sect,"key_right",KEY_RIGHT);
321
322 11 Abtn = zc_get_config(cfg_sect,"btn_a",2);
323 11 Bbtn = zc_get_config(cfg_sect,"btn_b",1);
324 11 Sbtn = zc_get_config(cfg_sect,"btn_s",10);
325 11 Mbtn = zc_get_config(cfg_sect,"btn_m",9);
326 11 Lbtn = zc_get_config(cfg_sect,"btn_l",5);
327 11 Rbtn = zc_get_config(cfg_sect,"btn_r",6);
328 11 Pbtn = zc_get_config(cfg_sect,"btn_p",12);
329 11 Exbtn1 = zc_get_config(cfg_sect,"btn_ex1",7);
330 11 Exbtn2 = zc_get_config(cfg_sect,"btn_ex2",8);
331 11 Exbtn3 = zc_get_config(cfg_sect,"btn_ex3",4);
332 11 Exbtn4 = zc_get_config(cfg_sect,"btn_ex4",3);
333
334 11 DUbtn = zc_get_config(cfg_sect,"btn_up",13);
335 11 DDbtn = zc_get_config(cfg_sect,"btn_down",14);
336 11 DLbtn = zc_get_config(cfg_sect,"btn_left",15);
337 11 DRbtn = zc_get_config(cfg_sect,"btn_right",16);
338
339 11 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
340
341 11 digi_volume = zc_get_config(cfg_sect,"digi",248);
342 11 midi_volume = zc_get_config(cfg_sect,"midi",255);
343 11 sfx_volume = zc_get_config(cfg_sect,"sfx",248);
344 11 emusic_volume = zc_get_config(cfg_sect,"emusic",248);
345 11 pan_style = zc_get_config(cfg_sect,"pan",1);
346 // 1 <= zcmusic_bufsz <= 128
347 11 zcmusic_bufsz = vbound(zc_get_config(cfg_sect,"zcmusic_bufsz",64),1,128);
348 11 volkeys = zc_get_config(cfg_sect,"volkeys",0)!=0;
349 11 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
350 11 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
351 11 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
352 11 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
353 11 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
354 #ifdef __EMSCRIPTEN__
355 if (em_is_mobile()) NameEntryMode = 2;
356 #endif
357 11 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
358 11 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
359 11 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
360 11 title_version = zc_get_config(cfg_sect,"title",2);
361 11 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
362 11 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
363
364 //default - scale x2, 640 x 480
365 11 window_width = resx = zc_get_config(cfg_sect,"resx",640);
366 11 window_height = resy = zc_get_config(cfg_sect,"resy",480);
367 11 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
368 11 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
369 11 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
370 //screen_scale = zc_get_config(cfg_sect,"screen_scale",2);
371
372 11 scanlines = zc_get_config(cfg_sect,"scanlines",0)!=0;
373 11 loadlast = zc_get_config(cfg_sect,"load_last",0);
374
375 // Fullscreen may be problematic on newer windows systems.
376 #ifdef _WIN32
377 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
378 #else
379 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",1);
380 #endif
381
382 11 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
383
384 //workaround for the 100% CPU bug. -Gleeok
385 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
386 11 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
387 #else
388 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
389 #endif
390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 frame_rest_suggest = zc_min(2, frame_rest_suggest);
391
392 11 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
393
394 #ifdef _WIN32
395 use_debug_console = (byte) zc_get_config(cfg_sect,"debug_console",0);
396 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
397 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
398 console_on_top = (byte) zc_get_config("CONSOLE","console_on_top",0);
399 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
400 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
401
402 // This seems to fix some problems on Windows 7
403 disable_direct_updating = (byte) zc_get_config("graphics","disable_direct_updating",1);
404
405 // This one's for Aero
406 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
407
408 // And this one fixes patches unloading on some MIDI setups
409 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
410 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
411 #else //UNIX
412 11 use_debug_console = false;//(byte) zc_get_config(cfg_sect,"debug_console",0);
413 11 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
414 11 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
415 11 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
416 #endif
417
418 11 char const* default_path = "";
419 11 strcpy(qstdir,get_config_string(cfg_sect,qst_dir_name,default_path));
420
421
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(strlen(qstdir)==0)
422 {
423 1 getcwd(qstdir,2048);
424 1 fix_filename_case(qstdir);
425 1 fix_filename_slashes(qstdir);
426 1 put_backslash(qstdir);
427 1 }
428 else
429 {
430 10 chop_path(qstdir);
431 }
432
433 11 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
434 11 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
435 11 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
436 11 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
437 11 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
438 11 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
439 11 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
440 11 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
441 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",1);
442 11 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
443 11 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
444 11 }
445
446 11 void save_game_configs()
447 {
448 11 packfile_password("");
449
450 11 set_config_string("ZCMODULE",qst_module_name,moduledata.module_name);
451
452 11 set_config_int(cfg_sect,"joystick_index",joystick_index);
453 11 set_config_int(cfg_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
454 11 set_config_int(cfg_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
455 11 set_config_int(cfg_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
456 11 set_config_int(cfg_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
457 11 set_config_int(cfg_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
458 11 set_config_int(cfg_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
459 11 set_config_int(cfg_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
460 11 set_config_int(cfg_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
461 11 set_config_int(cfg_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
462 11 set_config_int(cfg_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
463 11 set_config_int(cfg_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
464 11 set_config_int(cfg_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
465 11 set_config_int(cfg_sect,"analog_movement",analog_movement);
466
467 //cheat modifier keya
468
469 11 set_config_int(cfg_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
470 11 set_config_int(cfg_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
471 11 set_config_int(cfg_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
472 11 set_config_int(cfg_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
473
474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!replay_is_replaying())
475 {
476 11 set_config_int(cfg_sect,"key_a",Akey);
477 11 set_config_int(cfg_sect,"key_b",Bkey);
478 11 set_config_int(cfg_sect,"key_s",Skey);
479 11 set_config_int(cfg_sect,"key_l",Lkey);
480 11 set_config_int(cfg_sect,"key_r",Rkey);
481 11 set_config_int(cfg_sect,"key_p",Pkey);
482 11 set_config_int(cfg_sect,"key_ex1",Exkey1);
483 11 set_config_int(cfg_sect,"key_ex2",Exkey2);
484 11 set_config_int(cfg_sect,"key_ex3",Exkey3);
485 11 set_config_int(cfg_sect,"key_ex4",Exkey4);
486 11 set_config_int(cfg_sect,"key_up", DUkey);
487 11 set_config_int(cfg_sect,"key_down", DDkey);
488 11 set_config_int(cfg_sect,"key_left", DLkey);
489 11 set_config_int(cfg_sect,"key_right",DRkey);
490 11 }
491
492 11 set_config_int(cfg_sect,"btn_a",Abtn);
493 11 set_config_int(cfg_sect,"btn_b",Bbtn);
494 11 set_config_int(cfg_sect,"btn_s",Sbtn);
495 11 set_config_int(cfg_sect,"btn_m",Mbtn);
496 11 set_config_int(cfg_sect,"btn_l",Lbtn);
497 11 set_config_int(cfg_sect,"btn_r",Rbtn);
498 11 set_config_int(cfg_sect,"btn_p",Pbtn);
499 11 set_config_int(cfg_sect,"btn_ex1",Exbtn1);
500 11 set_config_int(cfg_sect,"btn_ex2",Exbtn2);
501 11 set_config_int(cfg_sect,"btn_ex3",Exbtn3);
502 11 set_config_int(cfg_sect,"btn_ex4",Exbtn4);
503
504 11 set_config_int(cfg_sect,"btn_up",DUbtn);
505 11 set_config_int(cfg_sect,"btn_down",DDbtn);
506 11 set_config_int(cfg_sect,"btn_left",DLbtn);
507 11 set_config_int(cfg_sect,"btn_right",DRbtn);
508
509 11 set_config_int(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
510
511 11 set_config_int(cfg_sect,"digi",digi_volume);
512 11 set_config_int(cfg_sect,"midi",midi_volume);
513 11 set_config_int(cfg_sect,"sfx",sfx_volume);
514 11 set_config_int(cfg_sect,"emusic",emusic_volume);
515 11 set_config_int(cfg_sect,"pan",pan_style);
516 11 set_config_int(cfg_sect,"zcmusic_bufsz",zcmusic_bufsz);
517 11 set_config_int(cfg_sect,"volkeys",(int32_t)volkeys);
518 11 set_config_int(cfg_sect,"vsync",zc_vsync);
519 11 set_config_int(cfg_sect,"throttlefps", (int32_t)Throttlefps);
520 11 set_config_int(cfg_sect,"translayers",(int32_t)TransLayers);
521 11 set_config_int(cfg_sect,"snapshot_format",SnapshotFormat);
522 11 set_config_int(cfg_sect,"name_entry_mode",NameEntryMode);
523 11 set_config_int(cfg_sect,"showfps",(int32_t)ShowFPS);
524 11 set_config_int(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
525 11 set_config_int(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
526 11 set_config_int(cfg_sect,"drag_aspect",(int32_t)DragAspect);
527 11 set_config_int(cfg_sect,"fastquit",(int32_t)NESquit);
528 11 set_config_int(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
529 11 set_config_int(cfg_sect,"title",title_version);
530 //set_config_int(cfg_sect,"lister_pattern_matching",abc_patternmatch); //Enable once there is a GUI way to toggle this.
531
532
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
533 {
534 window_width = al_get_display_width(all_get_display()) / gethorizontalscale();
535 window_height = al_get_display_height(all_get_display()) / getverticalscale();
536 }
537
538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
539 {
540 int o_window_x, o_window_y;
541 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
542 set_config_int(cfg_sect,"window_x",o_window_x);
543 set_config_int(cfg_sect,"window_y",o_window_y);
544 }
545
546 11 set_config_int(cfg_sect,"resx",window_width);
547 11 set_config_int(cfg_sect,"resy",window_height);
548
549 //sbig depricated as of 2.5 RC3. handled exclusively by resx, resy now.
550 //set_config_int(cfg_sect,"screen_scale",screen_scale);
551 //set_config_int(cfg_sect,"sbig",sbig);
552 //set_config_int(cfg_sect,"sbig2",sbig2);
553
554 11 set_config_int(cfg_sect,"scanlines",scanlines);
555 11 set_config_int(cfg_sect,"load_last",loadlast);
556 11 chop_path(qstdir);
557 11 set_config_string(cfg_sect,qst_dir_name,qstdir);
558 11 set_config_string("SAVEFILE","save_filename",save_file_name);
559 11 set_config_int(cfg_sect,"ss_enable",ss_enable);
560 11 set_config_int(cfg_sect,"ss_after",ss_after);
561 11 set_config_int(cfg_sect,"ss_speed",ss_speed);
562 11 set_config_int(cfg_sect,"ss_density",ss_density);
563 11 set_config_int(cfg_sect,"heart_beep",heart_beep);
564 11 set_config_int(cfg_sect,"gui_colorset",gui_colorset);
565 11 set_config_int(cfg_sect,"use_sfx_dat",sfxdat);
566 11 set_config_int(cfg_sect,"fullscreen",fullscreen);
567 11 set_config_int(cfg_sect,"color_depth",zc_color_depth);
568 11 set_config_int(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
569 11 set_config_int(cfg_sect,"force_exit",forceExit);
570
571 #ifdef _WIN32
572 set_config_int(cfg_sect,"debug_console",use_debug_console);
573 set_config_int("CONSOLE","print_ZASM",zasm_debugger);
574 set_config_int("CONSOLE","ZScript_Debugger",zscript_debugger);
575 set_config_int("CONSOLE","console_on_top",console_on_top);
576 //set_config_int(cfg_sect,"use_win7_key_fix",use_win7_keyboard_fix);
577 set_config_int(cfg_sect,"zc_win_proc_fix",use_win32_proc);
578 set_config_int("graphics","disable_direct_updating",disable_direct_updating);
579 set_config_int("zeldadx","use_dwm_flush",use_dwm_flush);
580 set_config_int("zeldadx","midi_patch_fix",midi_patch_fix);
581 set_config_int("CONSOLE","monochrome_debuggers",monochrome_console);
582 set_config_int("zeldadx","debug_console",zconsole);
583 #endif
584
585 #ifdef ALLEGRO_LINUX
586 set_config_string("sound","patches",samplepath); // set to sample sound path set for DIGMIDI driver in Linux ~ Takuya
587 #endif
588
589 11 set_config_int(cfg_sect,"save_indicator",use_save_indicator);
590 11 set_config_int(cfg_sect,"zc_192b163_warp_compatibility",zc_192b163_warp_compatibility);
591
592 11 flush_config_file();
593 #ifdef __EMSCRIPTEN__
594 em_sync_fs();
595 #endif
596 11 }
597
598 //----------------------------------------------------------------
599
600 // Timers
601
602 28 void fps_callback()
603 {
604 28 lastfps=framecnt;
605 28 dword tempsecs = fps_secs;
606 28 ++tempsecs;
607 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
608 28 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
609 28 ++fps_secs;
610 28 framecnt=0;
611 28 }
612
613 END_OF_FUNCTION(fps_callback)
614
615 11 int32_t Z_init_timers()
616 {
617 static bool didit = false;
618 const static char *err_str = "Couldn't allocate timer";
619 11 err_str = err_str; //Unused variable warning
620
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(didit)
622 return 1;
623
624 11 didit = true;
625
626 LOCK_VARIABLE(lastfps);
627 LOCK_VARIABLE(framecnt);
628 LOCK_FUNCTION(fps_callback);
629
630
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
631 return 0;
632
633 11 return 1;
634 11 }
635
636 void Z_remove_timers()
637 {
638 remove_int(fps_callback);
639 }
640
641 //----------------------------------------------------------------
642
643 void go()
644 {
645 scare_mouse();
646 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
647 unscare_mouse();
648 }
649
650 void comeback()
651 {
652 scare_mouse();
653 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
654 unscare_mouse();
655 }
656
657 void dump_pal(BITMAP *dest)
658 {
659 for(int32_t i=0; i<256; i++)
660 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
661 }
662
663 void show_paused(BITMAP *target)
664 {
665 // return;
666 char buf[7] = "PAUSED";
667
668 for(int32_t i=0; buf[i]!=0; i++)
669 buf[i]+=0x60;
670
671 // text_mode(-1);
672 if(sbig)
673 {
674 int32_t x = scrx+40-((screen_scale-1)*120);
675 int32_t y = scry+224+((screen_scale-1)*104);
676 textout_ex(target,zfont,buf,x,y,-1,-1);
677 }
678 else
679 textout_ex(target,zfont,buf,scrx+40,scry+224,-1,-1);
680 }
681
682 void show_fps(BITMAP *target)
683 {
684 char buf[50];
685
686 // text_mode(-1);
687 sprintf(buf,"%2d/60",lastfps);
688
689 // sprintf(buf,"%d/%u/%f/%u",lastfps,int32_t(avgfps),avgfps,fps_secs);
690 for(int32_t i=0; buf[i]!=0; i++)
691 if(buf[i]!=' ')
692 buf[i]+=0x60;
693
694 if(sbig)
695 {
696 int32_t x = scrx+40-((screen_scale-1)*120);
697 int32_t y = scry+216+((screen_scale-1)*104);
698 textout_ex(target,zfont,buf,x,y,-1,-1);
699 // textout_ex(target,zfont,buf,scrx+40-120,scry+216+104,-1,-1);
700 }
701 else
702 {
703 textout_ex(target,zfont,buf,scrx+40,scry+216,-1,-1);
704 }
705 }
706
707 3 void show_saving(BITMAP *target)
708 {
709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!use_save_indicator)
710 3 return;
711
712 char buf[10] = "SAVING...";
713
714 for(int32_t i=0; buf[i]!=0; i++)
715 buf[i]+=0x60;
716
717 if(sbig)
718 {
719 int32_t x = scrx+200+((screen_scale-1)*120);
720 int32_t y = scry+224+((screen_scale-1)*104);
721 textout_ex(target,zfont,buf,x,y,-1,-1);
722 }
723 else
724 textout_ex(target,zfont,buf,scrx+200,scry+224,-1,-1);
725 3 }
726
727 3132 void show_replay_controls(BITMAP *target)
728 {
729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if (!replay_is_replaying())
730 return;
731
732 3132 std::string text = replay_get_buttons_string();
733
734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if(sbig)
735 {
736 3132 int32_t x = scrx+140+((screen_scale-1)*120);
737 3132 int32_t y = scry+224+((screen_scale-1)*104);
738
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 textout_ex(target,zfont,text.c_str(),x,y,-1,0);
739 3132 }
740 else
741 textout_ex(target,zfont,text.c_str(),scrx+140,scry+224,-1,0);
742 3132 }
743
744 //----------------------------------------------------------------
745
746 //Handles converting the mouse sprite from the .dat file
747 11 void load_mouse()
748 {
749 11 system_pal();
750 11 scare_mouse();
751 11 set_mouse_sprite(NULL);
752
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 int32_t sz = vbound(int32_t(16*(is_large ? get_config_float("zeldadx","cursor_scale_large",1.5) : get_config_float("zeldadx","cursor_scale_small",1))),16,80);
753
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t j = 0; j < 4; ++j)
754 {
755 44 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
756 44 BITMAP* subbmp = create_bitmap_ex(8,16,16);
757
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(zcmouse[j])
758 destroy_bitmap(zcmouse[j]);
759 44 zcmouse[j] = create_bitmap_ex(8,sz,sz);
760 44 clear_bitmap(zcmouse[j]);
761 44 clear_bitmap(tmpbmp);
762 44 clear_bitmap(subbmp);
763 44 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
764
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 44 times.
748 for(int32_t x = 0; x < 16; ++x)
765 {
766
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 704 times.
11968 for(int32_t y = 0; y < 16; ++y)
767 {
768 11264 int32_t color = getpixel(tmpbmp, x, y);
769
5/5
✓ Branch 0 taken 10362 times.
✓ Branch 1 taken 209 times.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 198 times.
11264 switch(color)
770 {
771 case dvc(1):
772 209 color = jwin_pal[jcCURSORMISC];
773 209 break;
774 case dvc(2):
775 242 color = jwin_pal[jcCURSOROUTLINE];
776 242 break;
777 case dvc(3):
778 253 color = jwin_pal[jcCURSORLIGHT];
779 253 break;
780 case dvc(5):
781 198 color = jwin_pal[jcCURSORDARK];
782 198 break;
783 }
784 11264 putpixel(subbmp, x, y, color);
785 11264 }
786 704 }
787
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(sz!=16)
788 44 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
789 else
790 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
791 44 destroy_bitmap(tmpbmp);
792 44 destroy_bitmap(subbmp);
793 44 }
794 11 set_mouse_sprite(zcmouse[0]);
795 11 unscare_mouse();
796 11 game_pal();
797 11 }
798
799 // sets the video mode and initializes the palette and mouse sprite
800 11 bool game_vid_mode(int32_t mode,int32_t wait)
801 {
802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
803 {
804 return false;
805 }
806
807 11 scrx = (resx-320)>>1;
808 11 scry = (resy-240)>>1;
809
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t q = 0; q < 4; ++q)
810 44 zcmouse[q] = NULL;
811 11 load_mouse();
812 11 set_mouse_sprite(zcmouse[0]);
813
814
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 11 times.
187 for(int32_t i=240; i<256; i++)
815 176 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
816
817 11 set_palette(RAMpal);
818 11 clear_to_color(screen,BLACK);
819
820 11 rest(wait);
821 11 return true;
822 11 }
823
824 void null_quest()
825 {
826 char qstdat_string[2048];
827 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
828 strcat(qstdat_string,"#NESQST_NEW_QST");
829
830 #ifdef __EMSCRIPTEN__
831 // The quest template data file is not included because it's really big and isn't really needed
832 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
833 // which is much smaller.
834 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
835 #endif
836
837 byte skip_flags[4] = { 0 };
838
839 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
840 }
841
842 void init_NES_mode()
843 {
844 /*
845 // qst.dat may not load correctly without this...
846 QHeader.templatepath[0]='\0';
847
848 if(!init_colordata(true, &QHeader, &QMisc))
849 {
850 return;
851 }
852
853 loadfullpal();
854 init_tiles(false, &QHeader);
855 */
856 null_quest();
857 }
858
859 //----------------------------------------------------------------
860
861 qword trianglelines[16]=
862 {
863 0x0000000000000000ULL,
864 0xFD00000000000000ULL,
865 0xFDFD000000000000ULL,
866 0xFDFDFD0000000000ULL,
867 0xFDFDFDFD00000000ULL,
868 0xFDFDFDFDFD000000ULL,
869 0xFDFDFDFDFDFD0000ULL,
870 0xFDFDFDFDFDFDFD00ULL,
871 0xFDFDFDFDFDFDFDFDULL,
872 0x00FDFDFDFDFDFDFDULL,
873 0x0000FDFDFDFDFDFDULL,
874 0x000000FDFDFDFDFDULL,
875 0x00000000FDFDFDFDULL,
876 0x0000000000FDFDFDULL,
877 0x000000000000FDFDULL,
878 0x00000000000000FDULL,
879 };
880
881 word screen_triangles[28][32];
882 /*
883 qword triangles[4][16]= //[direction][value]
884 {
885 {
886 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
887 },
888 {
889 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
890 },
891 {
892 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
893 },
894 {
895 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
896 }
897 };
898 */
899
900
901 /*
902 byte triangles[4][16][8]= //[direction][value][line]
903 {
904 {
905 {
906 0, 0, 0, 0, 0, 0, 0, 0
907 },
908 {
909 1, 0, 0, 0, 0, 0, 0, 0
910 },
911 {
912 2, 1, 0, 0, 0, 0, 0, 0
913 },
914 {
915 3, 2, 1, 0, 0, 0, 0, 0
916 },
917 {
918 4, 3, 2, 1, 0, 0, 0, 0
919 },
920 {
921 5, 4, 3, 2, 1, 0, 0, 0
922 },
923 {
924 6, 5, 4, 3, 2, 1, 0, 0
925 },
926 {
927 7, 6, 5, 4, 3, 2, 1, 0
928 },
929 {
930 8, 7, 6, 5, 4, 3, 2, 1
931 },
932 {
933 8, 8, 7, 6, 5, 4, 3, 2
934 },
935 {
936 8, 8, 8, 7, 6, 5, 4, 3
937 },
938 {
939 8, 8, 8, 8, 7, 6, 5, 4
940 },
941 {
942 8, 8, 8, 8, 8, 7, 6, 5
943 },
944 {
945 8, 8, 8, 8, 8, 8, 7, 6
946 },
947 {
948 8, 8, 8, 8, 8, 8, 8, 7
949 },
950 {
951 8, 8, 8, 8, 8, 8, 8, 8
952 }
953 },
954 {
955 {
956 0, 0, 0, 0, 0, 0, 0, 0
957 },
958 {
959 15, 0, 0, 0, 0, 0, 0, 0
960 },
961 {
962 14, 15, 0, 0, 0, 0, 0, 0
963 },
964 {
965 13, 14, 15, 0, 0, 0, 0, 0
966 },
967 {
968 12, 13, 14, 15, 0, 0, 0, 0
969 },
970 {
971 11, 12, 13, 14, 15, 0, 0, 0
972 },
973 {
974 10, 11, 12, 13, 14, 15, 0, 0
975 },
976 {
977 9, 10, 11, 12, 13, 14, 15, 0
978 },
979 {
980 8, 9, 10, 11, 12, 13, 14, 15
981 },
982 {
983 8, 8, 9, 10, 11, 12, 13, 14
984 },
985 {
986 8, 8, 8, 9, 10, 11, 12, 13
987 },
988 {
989 8, 8, 8, 8, 9, 10, 11, 12
990 },
991 {
992 8, 8, 8, 8, 8, 9, 10, 11
993 },
994 {
995 8, 8, 8, 8, 8, 8, 9, 10
996 },
997 {
998 8, 8, 8, 8, 8, 8, 8, 9
999 },
1000 {
1001 8, 8, 8, 8, 8, 8, 8, 8
1002 }
1003 },
1004 {
1005 {
1006 0, 0, 0, 0, 0, 0, 0, 0
1007 },
1008 {
1009 0, 0, 0, 0, 0, 0, 0, 1
1010 },
1011 {
1012 0, 0, 0, 0, 0, 0, 1, 2
1013 },
1014 {
1015 0, 0, 0, 0, 0, 1, 2, 3
1016 },
1017 {
1018 0, 0, 0, 0, 1, 2, 3, 4
1019 },
1020 {
1021 0, 0, 0, 1, 2, 3, 4, 5
1022 },
1023 {
1024 0, 0, 1, 2, 3, 4, 5, 6
1025 },
1026 {
1027 0, 1, 2, 3, 4, 5, 6, 7
1028 },
1029 {
1030 1, 2, 3, 4, 5, 6, 7, 8
1031 },
1032 {
1033 2, 3, 4, 5, 6, 7, 8, 8
1034 },
1035 {
1036 3, 4, 5, 6, 7, 8, 8, 8
1037 },
1038 {
1039 4, 5, 6, 7, 8, 8, 8, 8
1040 },
1041 {
1042 5, 6, 7, 8, 8, 8, 8, 8
1043 },
1044 {
1045 6, 7, 8, 8, 8, 8, 8, 8
1046 },
1047 {
1048 7, 8, 8, 8, 8, 8, 8, 8
1049 },
1050 {
1051 8, 8, 8, 8, 8, 8, 8, 8
1052 }
1053 },
1054 {
1055 {
1056 0, 0, 0, 0, 0, 0, 0, 0
1057 },
1058 {
1059 0, 0, 0, 0, 0, 0, 0, 15
1060 },
1061 {
1062 0, 0, 0, 0, 0, 0, 15, 14
1063 },
1064 {
1065 0, 0, 0, 0, 0, 15, 14, 13
1066 },
1067 {
1068 0, 0, 0, 0, 15, 14, 13, 12
1069 },
1070 {
1071 0, 0, 0, 15, 14, 13, 12, 11
1072 },
1073 {
1074 0, 0, 15, 14, 13, 12, 11, 10
1075 },
1076 {
1077 0, 15, 14, 13, 12, 11, 10, 9
1078 },
1079 {
1080 15, 14, 13, 12, 11, 10, 9, 8
1081 },
1082 {
1083 14, 13, 12, 11, 10, 9, 8, 8
1084 },
1085 {
1086 13, 12, 11, 10, 9, 8, 8, 8
1087 },
1088 {
1089 12, 11, 10, 9, 8, 8, 8, 8
1090 },
1091 {
1092 11, 10, 9, 8, 8, 8, 8, 8
1093 },
1094 {
1095 10, 9, 8, 8, 8, 8, 8, 8
1096 },
1097 {
1098 9, 8, 8, 8, 8, 8, 8, 8
1099 },
1100 {
1101 8, 8, 8, 8, 8, 8, 8, 8
1102 }
1103 }
1104 };
1105 */
1106
1107
1108
1109 /*
1110 for (int32_t blockrow=0; blockrow<30; ++i)
1111 {
1112 for (int32_t linerow=0; linerow<8; ++i)
1113 {
1114 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1115 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1116 {
1117 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1118 ++triangleline;
1119 }
1120 }
1121 }
1122 */
1123
1124 // the ULL suffixes are to prevent this warning:
1125 // warning: integer constant is too large for "int32_t" type
1126
1127 qword triangles[4][16][8]= //[direction][value][line]
1128 {
1129 {
1130 {
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL,
1138 0x0000000000000000ULL
1139 },
1140 {
1141 0xFD00000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL
1149 },
1150 {
1151 0xFDFD000000000000ULL,
1152 0xFD00000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL
1159 },
1160 {
1161 0xFDFDFD0000000000ULL,
1162 0xFDFD000000000000ULL,
1163 0xFD00000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL
1169 },
1170 {
1171 0xFDFDFDFD00000000ULL,
1172 0xFDFDFD0000000000ULL,
1173 0xFDFD000000000000ULL,
1174 0xFD00000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL
1179 },
1180 {
1181 0xFDFDFDFDFD000000ULL,
1182 0xFDFDFDFD00000000ULL,
1183 0xFDFDFD0000000000ULL,
1184 0xFDFD000000000000ULL,
1185 0xFD00000000000000ULL,
1186 0x0000000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL
1189 },
1190 {
1191 0xFDFDFDFDFDFD0000ULL,
1192 0xFDFDFDFDFD000000ULL,
1193 0xFDFDFDFD00000000ULL,
1194 0xFDFDFD0000000000ULL,
1195 0xFDFD000000000000ULL,
1196 0xFD00000000000000ULL,
1197 0x0000000000000000ULL,
1198 0x0000000000000000ULL
1199 },
1200 {
1201 0xFDFDFDFDFDFDFD00ULL,
1202 0xFDFDFDFDFDFD0000ULL,
1203 0xFDFDFDFDFD000000ULL,
1204 0xFDFDFDFD00000000ULL,
1205 0xFDFDFD0000000000ULL,
1206 0xFDFD000000000000ULL,
1207 0xFD00000000000000ULL,
1208 0x0000000000000000ULL
1209 },
1210 {
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFD00ULL,
1213 0xFDFDFDFDFDFD0000ULL,
1214 0xFDFDFDFDFD000000ULL,
1215 0xFDFDFDFD00000000ULL,
1216 0xFDFDFD0000000000ULL,
1217 0xFDFD000000000000ULL,
1218 0xFD00000000000000ULL
1219 },
1220 {
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFD00ULL,
1224 0xFDFDFDFDFDFD0000ULL,
1225 0xFDFDFDFDFD000000ULL,
1226 0xFDFDFDFD00000000ULL,
1227 0xFDFDFD0000000000ULL,
1228 0xFDFD000000000000ULL
1229 },
1230 {
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFD00ULL,
1235 0xFDFDFDFDFDFD0000ULL,
1236 0xFDFDFDFDFD000000ULL,
1237 0xFDFDFDFD00000000ULL,
1238 0xFDFDFD0000000000ULL
1239 },
1240 {
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFD00ULL,
1246 0xFDFDFDFDFDFD0000ULL,
1247 0xFDFDFDFDFD000000ULL,
1248 0xFDFDFDFD00000000ULL
1249 },
1250 {
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFD00ULL,
1257 0xFDFDFDFDFDFD0000ULL,
1258 0xFDFDFDFDFD000000ULL
1259 },
1260 {
1261 0xFDFDFDFDFDFDFDFDULL,
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFD00ULL,
1268 0xFDFDFDFDFDFD0000ULL
1269 },
1270 {
1271 0xFDFDFDFDFDFDFDFDULL,
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0xFDFDFDFDFDFDFDFDULL,
1278 0xFDFDFDFDFDFDFD00ULL
1279 },
1280 {
1281 0xFDFDFDFDFDFDFDFDULL,
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0xFDFDFDFDFDFDFDFDULL
1289 }
1290 },
1291 {
1292 {
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL,
1300 0x0000000000000000ULL
1301 },
1302 {
1303 0x00000000000000FDULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL
1311 },
1312 {
1313 0x000000000000FDFDULL,
1314 0x00000000000000FDULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL
1321 },
1322 {
1323 0x0000000000FDFDFDULL,
1324 0x000000000000FDFDULL,
1325 0x00000000000000FDULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL
1331 },
1332 {
1333 0x00000000FDFDFDFDULL,
1334 0x0000000000FDFDFDULL,
1335 0x000000000000FDFDULL,
1336 0x00000000000000FDULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0x0000000000000000ULL
1341 },
1342 {
1343 0x000000FDFDFDFDFDULL,
1344 0x00000000FDFDFDFDULL,
1345 0x0000000000FDFDFDULL,
1346 0x000000000000FDFDULL,
1347 0x00000000000000FDULL,
1348 0x0000000000000000ULL,
1349 0x0000000000000000ULL,
1350 0x0000000000000000ULL
1351 },
1352 {
1353 0x0000FDFDFDFDFDFDULL,
1354 0x000000FDFDFDFDFDULL,
1355 0x00000000FDFDFDFDULL,
1356 0x0000000000FDFDFDULL,
1357 0x000000000000FDFDULL,
1358 0x00000000000000FDULL,
1359 0x0000000000000000ULL,
1360 0x0000000000000000ULL
1361 },
1362 {
1363 0x00FDFDFDFDFDFDFDULL,
1364 0x0000FDFDFDFDFDFDULL,
1365 0x000000FDFDFDFDFDULL,
1366 0x00000000FDFDFDFDULL,
1367 0x0000000000FDFDFDULL,
1368 0x000000000000FDFDULL,
1369 0x00000000000000FDULL,
1370 0x0000000000000000ULL
1371 },
1372 {
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0x00FDFDFDFDFDFDFDULL,
1375 0x0000FDFDFDFDFDFDULL,
1376 0x000000FDFDFDFDFDULL,
1377 0x00000000FDFDFDFDULL,
1378 0x0000000000FDFDFDULL,
1379 0x000000000000FDFDULL,
1380 0x00000000000000FDULL
1381 },
1382 {
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0x00FDFDFDFDFDFDFDULL,
1386 0x0000FDFDFDFDFDFDULL,
1387 0x000000FDFDFDFDFDULL,
1388 0x00000000FDFDFDFDULL,
1389 0x0000000000FDFDFDULL,
1390 0x000000000000FDFDULL
1391 },
1392 {
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0x00FDFDFDFDFDFDFDULL,
1397 0x0000FDFDFDFDFDFDULL,
1398 0x000000FDFDFDFDFDULL,
1399 0x00000000FDFDFDFDULL,
1400 0x0000000000FDFDFDULL
1401 },
1402 {
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0x00FDFDFDFDFDFDFDULL,
1408 0x0000FDFDFDFDFDFDULL,
1409 0x000000FDFDFDFDFDULL,
1410 0x00000000FDFDFDFDULL
1411 },
1412 {
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL,
1418 0x00FDFDFDFDFDFDFDULL,
1419 0x0000FDFDFDFDFDFDULL,
1420 0x000000FDFDFDFDFDULL
1421 },
1422 {
1423 0xFDFDFDFDFDFDFDFDULL,
1424 0xFDFDFDFDFDFDFDFDULL,
1425 0xFDFDFDFDFDFDFDFDULL,
1426 0xFDFDFDFDFDFDFDFDULL,
1427 0xFDFDFDFDFDFDFDFDULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0x00FDFDFDFDFDFDFDULL,
1430 0x0000FDFDFDFDFDFDULL
1431 },
1432 {
1433 0xFDFDFDFDFDFDFDFDULL,
1434 0xFDFDFDFDFDFDFDFDULL,
1435 0xFDFDFDFDFDFDFDFDULL,
1436 0xFDFDFDFDFDFDFDFDULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0x00FDFDFDFDFDFDFDULL
1441 },
1442 {
1443 0xFDFDFDFDFDFDFDFDULL,
1444 0xFDFDFDFDFDFDFDFDULL,
1445 0xFDFDFDFDFDFDFDFDULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL
1451 }
1452 },
1453 {
1454 {
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0x0000000000000000ULL,
1458 0x0000000000000000ULL,
1459 0x0000000000000000ULL,
1460 0x0000000000000000ULL,
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL
1463 },
1464 {
1465 0x0000000000000000ULL,
1466 0x0000000000000000ULL,
1467 0x0000000000000000ULL,
1468 0x0000000000000000ULL,
1469 0x0000000000000000ULL,
1470 0x0000000000000000ULL,
1471 0x0000000000000000ULL,
1472 0xFD00000000000000ULL
1473 },
1474 {
1475 0x0000000000000000ULL,
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0xFD00000000000000ULL,
1482 0xFDFD000000000000ULL
1483 },
1484 {
1485 0x0000000000000000ULL,
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0xFD00000000000000ULL,
1491 0xFDFD000000000000ULL,
1492 0xFDFDFD0000000000ULL
1493 },
1494 {
1495 0x0000000000000000ULL,
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0xFD00000000000000ULL,
1500 0xFDFD000000000000ULL,
1501 0xFDFDFD0000000000ULL,
1502 0xFDFDFDFD00000000ULL
1503 },
1504 {
1505 0x0000000000000000ULL,
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0xFD00000000000000ULL,
1509 0xFDFD000000000000ULL,
1510 0xFDFDFD0000000000ULL,
1511 0xFDFDFDFD00000000ULL,
1512 0xFDFDFDFDFD000000ULL
1513 },
1514 {
1515 0x0000000000000000ULL,
1516 0x0000000000000000ULL,
1517 0xFD00000000000000ULL,
1518 0xFDFD000000000000ULL,
1519 0xFDFDFD0000000000ULL,
1520 0xFDFDFDFD00000000ULL,
1521 0xFDFDFDFDFD000000ULL,
1522 0xFDFDFDFDFDFD0000ULL
1523 },
1524 {
1525 0x0000000000000000ULL,
1526 0xFD00000000000000ULL,
1527 0xFDFD000000000000ULL,
1528 0xFDFDFD0000000000ULL,
1529 0xFDFDFDFD00000000ULL,
1530 0xFDFDFDFDFD000000ULL,
1531 0xFDFDFDFDFDFD0000ULL,
1532 0xFDFDFDFDFDFDFD00ULL
1533 },
1534 {
1535 0xFD00000000000000ULL,
1536 0xFDFD000000000000ULL,
1537 0xFDFDFD0000000000ULL,
1538 0xFDFDFDFD00000000ULL,
1539 0xFDFDFDFDFD000000ULL,
1540 0xFDFDFDFDFDFD0000ULL,
1541 0xFDFDFDFDFDFDFD00ULL,
1542 0xFDFDFDFDFDFDFDFDULL
1543 },
1544 {
1545 0xFDFD000000000000ULL,
1546 0xFDFDFD0000000000ULL,
1547 0xFDFDFDFD00000000ULL,
1548 0xFDFDFDFDFD000000ULL,
1549 0xFDFDFDFDFDFD0000ULL,
1550 0xFDFDFDFDFDFDFD00ULL,
1551 0xFDFDFDFDFDFDFDFDULL,
1552 0xFDFDFDFDFDFDFDFDULL
1553 },
1554 {
1555 0xFDFDFD0000000000ULL,
1556 0xFDFDFDFD00000000ULL,
1557 0xFDFDFDFDFD000000ULL,
1558 0xFDFDFDFDFDFD0000ULL,
1559 0xFDFDFDFDFDFDFD00ULL,
1560 0xFDFDFDFDFDFDFDFDULL,
1561 0xFDFDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL
1563 },
1564 {
1565 0xFDFDFDFD00000000ULL,
1566 0xFDFDFDFDFD000000ULL,
1567 0xFDFDFDFDFDFD0000ULL,
1568 0xFDFDFDFDFDFDFD00ULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL
1573 },
1574 {
1575 0xFDFDFDFDFD000000ULL,
1576 0xFDFDFDFDFDFD0000ULL,
1577 0xFDFDFDFDFDFDFD00ULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL
1583 },
1584 {
1585 0xFDFDFDFDFDFD0000ULL,
1586 0xFDFDFDFDFDFDFD00ULL,
1587 0xFDFDFDFDFDFDFDFDULL,
1588 0xFDFDFDFDFDFDFDFDULL,
1589 0xFDFDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL
1593 },
1594 {
1595 0xFDFDFDFDFDFDFD00ULL,
1596 0xFDFDFDFDFDFDFDFDULL,
1597 0xFDFDFDFDFDFDFDFDULL,
1598 0xFDFDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL
1603 },
1604 {
1605 0xFDFDFDFDFDFDFDFDULL,
1606 0xFDFDFDFDFDFDFDFDULL,
1607 0xFDFDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL
1613 }
1614 },
1615 {
1616 {
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x0000000000000000ULL,
1620 0x0000000000000000ULL,
1621 0x0000000000000000ULL,
1622 0x0000000000000000ULL,
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL
1625 },
1626 {
1627 0x0000000000000000ULL,
1628 0x0000000000000000ULL,
1629 0x0000000000000000ULL,
1630 0x0000000000000000ULL,
1631 0x0000000000000000ULL,
1632 0x0000000000000000ULL,
1633 0x0000000000000000ULL,
1634 0x00000000000000FDULL
1635 },
1636 {
1637 0x0000000000000000ULL,
1638 0x0000000000000000ULL,
1639 0x0000000000000000ULL,
1640 0x0000000000000000ULL,
1641 0x0000000000000000ULL,
1642 0x0000000000000000ULL,
1643 0x00000000000000FDULL,
1644 0x000000000000FDFDULL
1645 },
1646 {
1647 0x0000000000000000ULL,
1648 0x0000000000000000ULL,
1649 0x0000000000000000ULL,
1650 0x0000000000000000ULL,
1651 0x0000000000000000ULL,
1652 0x00000000000000FDULL,
1653 0x000000000000FDFDULL,
1654 0x0000000000FDFDFDULL
1655 },
1656 {
1657 0x0000000000000000ULL,
1658 0x0000000000000000ULL,
1659 0x0000000000000000ULL,
1660 0x0000000000000000ULL,
1661 0x00000000000000FDULL,
1662 0x000000000000FDFDULL,
1663 0x0000000000FDFDFDULL,
1664 0x00000000FDFDFDFDULL
1665 },
1666 {
1667 0x0000000000000000ULL,
1668 0x0000000000000000ULL,
1669 0x0000000000000000ULL,
1670 0x00000000000000FDULL,
1671 0x000000000000FDFDULL,
1672 0x0000000000FDFDFDULL,
1673 0x00000000FDFDFDFDULL,
1674 0x000000FDFDFDFDFDULL
1675 },
1676 {
1677 0x0000000000000000ULL,
1678 0x0000000000000000ULL,
1679 0x00000000000000FDULL,
1680 0x000000000000FDFDULL,
1681 0x0000000000FDFDFDULL,
1682 0x00000000FDFDFDFDULL,
1683 0x000000FDFDFDFDFDULL,
1684 0x0000FDFDFDFDFDFDULL
1685 },
1686 {
1687 0x0000000000000000ULL,
1688 0x00000000000000FDULL,
1689 0x000000000000FDFDULL,
1690 0x0000000000FDFDFDULL,
1691 0x00000000FDFDFDFDULL,
1692 0x000000FDFDFDFDFDULL,
1693 0x0000FDFDFDFDFDFDULL,
1694 0x00FDFDFDFDFDFDFDULL
1695 },
1696 {
1697 0x00000000000000FDULL,
1698 0x000000000000FDFDULL,
1699 0x0000000000FDFDFDULL,
1700 0x00000000FDFDFDFDULL,
1701 0x000000FDFDFDFDFDULL,
1702 0x0000FDFDFDFDFDFDULL,
1703 0x00FDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL
1705 },
1706 {
1707 0x000000000000FDFDULL,
1708 0x0000000000FDFDFDULL,
1709 0x00000000FDFDFDFDULL,
1710 0x000000FDFDFDFDFDULL,
1711 0x0000FDFDFDFDFDFDULL,
1712 0x00FDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL,
1714 0xFDFDFDFDFDFDFDFDULL
1715 },
1716 {
1717 0x0000000000FDFDFDULL,
1718 0x00000000FDFDFDFDULL,
1719 0x000000FDFDFDFDFDULL,
1720 0x0000FDFDFDFDFDFDULL,
1721 0x00FDFDFDFDFDFDFDULL,
1722 0xFDFDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL
1725 },
1726 {
1727 0x00000000FDFDFDFDULL,
1728 0x000000FDFDFDFDFDULL,
1729 0x0000FDFDFDFDFDFDULL,
1730 0x00FDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL
1735 },
1736 {
1737 0x000000FDFDFDFDFDULL,
1738 0x0000FDFDFDFDFDFDULL,
1739 0x00FDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL,
1742 0xFDFDFDFDFDFDFDFDULL,
1743 0xFDFDFDFDFDFDFDFDULL,
1744 0xFDFDFDFDFDFDFDFDULL
1745 },
1746 {
1747 0x0000FDFDFDFDFDFDULL,
1748 0x00FDFDFDFDFDFDFDULL,
1749 0xFDFDFDFDFDFDFDFDULL,
1750 0xFDFDFDFDFDFDFDFDULL,
1751 0xFDFDFDFDFDFDFDFDULL,
1752 0xFDFDFDFDFDFDFDFDULL,
1753 0xFDFDFDFDFDFDFDFDULL,
1754 0xFDFDFDFDFDFDFDFDULL
1755 },
1756 {
1757 0x00FDFDFDFDFDFDFDULL,
1758 0xFDFDFDFDFDFDFDFDULL,
1759 0xFDFDFDFDFDFDFDFDULL,
1760 0xFDFDFDFDFDFDFDFDULL,
1761 0xFDFDFDFDFDFDFDFDULL,
1762 0xFDFDFDFDFDFDFDFDULL,
1763 0xFDFDFDFDFDFDFDFDULL,
1764 0xFDFDFDFDFDFDFDFDULL
1765 },
1766 {
1767 0xFDFDFDFDFDFDFDFDULL,
1768 0xFDFDFDFDFDFDFDFDULL,
1769 0xFDFDFDFDFDFDFDFDULL,
1770 0xFDFDFDFDFDFDFDFDULL,
1771 0xFDFDFDFDFDFDFDFDULL,
1772 0xFDFDFDFDFDFDFDFDULL,
1773 0xFDFDFDFDFDFDFDFDULL,
1774 0xFDFDFDFDFDFDFDFDULL
1775 }
1776 }
1777 };
1778
1779 int32_t black_opening_count=0;
1780 int32_t black_opening_x,black_opening_y;
1781 int32_t black_opening_shape;
1782
1783 int32_t choose_opening_shape()
1784 {
1785 // First, count how many bits are set
1786 int32_t numBits=0;
1787 int32_t bitCounter;
1788
1789 for(int32_t i=0; i<bosMAX; i++)
1790 {
1791 if(COOLSCROLL&(1<<i))
1792 numBits++;
1793 }
1794
1795 // Shouldn't happen...
1796 if(numBits==0)
1797 return bosCIRCLE;
1798
1799 // Pick a bit
1800 bitCounter=zc_rand()%numBits+1;
1801
1802 for(int32_t i=0; i<bosMAX; i++)
1803 {
1804 // If this bit is set, decrement the bit counter
1805 if(COOLSCROLL&(1<<i))
1806 bitCounter--;
1807
1808 // When the counter hits 0, return a value based on
1809 // which bit it stopped on.
1810 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1811 if(bitCounter==0)
1812 return i;
1813 }
1814
1815 // Shouldn't be necessary, but the compiler might complain, at least
1816 return bosCIRCLE;
1817 }
1818
1819 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1820 {
1821 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1822
1823 int32_t w=256, h=224;
1824 int32_t blockrows=28, blockcolumns=32;
1825 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1826
1827 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1828 {
1829 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1830 {
1831 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1832 }
1833 }
1834
1835 black_opening_count = 66;
1836 black_opening_x = x;
1837 black_opening_y = y;
1838 lensclk = 0;
1839 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1840
1841
1842 if(black_opening_shape == bosFADEBLACK)
1843 {
1844 refreshTints();
1845 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1846 }
1847 if(wait)
1848 {
1849 FFCore.warpScriptCheck();
1850 for(int32_t i=0; i<66; i++)
1851 {
1852 draw_screen(tmpscr);
1853 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1854 syskeys();
1855 advanceframe(true);
1856
1857 if(Quit)
1858 {
1859 break;
1860 }
1861 }
1862 }
1863 }
1864
1865 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1866 {
1867 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1868
1869 int32_t w=256, h=224;
1870 int32_t blockrows=28, blockcolumns=32;
1871 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1872
1873 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1874 {
1875 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1876 {
1877 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1878 }
1879 }
1880
1881 black_opening_count = -66;
1882 black_opening_x = x;
1883 black_opening_y = y;
1884 lensclk = 0;
1885 if(black_opening_shape == bosFADEBLACK)
1886 {
1887 refreshTints();
1888 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1889 }
1890 if(wait)
1891 {
1892 FFCore.warpScriptCheck();
1893 for(int32_t i=0; i<66; i++)
1894 {
1895 draw_screen(tmpscr);
1896 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1897 syskeys();
1898 advanceframe(true);
1899
1900 if(Quit)
1901 {
1902 break;
1903 }
1904 }
1905 }
1906 }
1907
1908 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1909 {
1910 clear_to_color(tmp_scr,BLACK);
1911 int32_t w=256, h=224;
1912
1913 switch(black_opening_shape)
1914 {
1915 case bosOVAL:
1916 {
1917 double new_w=(w/2)+abs(w/2-x);
1918 double new_h=(h/2)+abs(h/2-y);
1919 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1920 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1921 break;
1922 }
1923
1924 case bosTRIANGLE:
1925 {
1926 double new_w=(w/2)+abs(w/2-x);
1927 double new_h=(h/2)+abs(h/2-y);
1928 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1929 double P2= (PI/2);
1930 double P23=(2*PI/3);
1931 double P43=(4*PI/3);
1932 double Pa= (-4*PI*a/(3*max_a));
1933 double angle=P2+Pa;
1934 double a0=angle;
1935 double a2=angle+P23;
1936 double a4=angle+P43;
1937 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1938 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1939 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1940 0);
1941 break;
1942 }
1943
1944 case bosSMAS:
1945 {
1946 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1947
1948 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1949 {
1950 for(int32_t linerow=0; linerow<8; ++linerow)
1951 {
1952 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1953
1954 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1955 {
1956 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1957 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1958 [linerow];
1959 ++triangleline;
1960
1961 if(linerow==0)
1962 {
1963 }
1964 }
1965 }
1966 }
1967
1968 break;
1969 }
1970
1971 case bosFADEBLACK:
1972 {
1973 if(black_opening_count<0)
1974 {
1975 black_fade(zc_min(-black_opening_count,63));
1976 }
1977 else if(black_opening_count>0)
1978 {
1979 black_fade(63-zc_max(black_opening_count-3,0));
1980 }
1981 else black_fade(0);
1982 return; //no blitting from tmp_scr!
1983 }
1984
1985 case bosCIRCLE:
1986 default:
1987 {
1988 double new_w=(w/2)+abs(w/2-x);
1989 double new_h=(h/2)+abs(h/2-y);
1990 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1991 //circlefill(tmp_scr,x,y,a<<3,0);
1992 circlefill(tmp_scr,x,y,r,0);
1993 break;
1994 }
1995 }
1996
1997 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1998 }
1999
2000
2001 void black_fade(int32_t fadeamnt)
2002 {
2003 for(int32_t i=0; i < 0xEF; i++)
2004 {
2005 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
2006 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
2007 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
2008 }
2009
2010 refreshpal = true;
2011 }
2012
2013 //----------------------------------------------------------------
2014
2015 127 bool item_disabled(int32_t item) //is this item disabled?
2016 {
2017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 return (item>=0 && game->items_off[item] != 0);
2018 }
2019
2020 1888 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
2021 {
2022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1888 times.
1888 if(current_item(item_type, true) >=item)
2023 {
2024 return true;
2025 }
2026
2027 1888 return false;
2028 1888 }
2029
2030 1531 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
2031 {
2032
4/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1243 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✓ Branch 7 taken 96 times.
✓ Branch 8 taken 96 times.
1531 switch(item_type)
2033 {
2034 case itype_bomb:
2035 case itype_sbomb:
2036 {
2037 int32_t itemid = getItemID(itemsbuf, item_type, it);
2038
2039 if(itemid == -1)
2040 return false;
2041
2042 return (game->get_item(itemid));
2043 }
2044
2045 case itype_clock:
2046 {
2047 1243 int32_t itemid = getItemID(itemsbuf, item_type, it);
2048
2049
2/4
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1243 times.
✗ Branch 3 not taken.
1243 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2050 return (game->get_item(itemid));
2051 1243 return Hero.getClock()?1:0;
2052 }
2053
2054 case itype_key:
2055 return (game->get_keys()>0);
2056
2057 case itype_magiccontainer:
2058 return (game->get_maxmagic()>=game->get_mp_per_block());
2059
2060 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2061 {
2062 switch(it)
2063 {
2064 case -2:
2065 {
2066 for(int32_t i=0; i<MAXLEVELS; i++)
2067 {
2068 if(game->lvlitems[i]&liTRIFORCE)
2069 {
2070 return true;
2071 }
2072 }
2073
2074 return false;
2075 }
2076
2077 case -1:
2078 return (game->lvlitems[dlevel]&liTRIFORCE);
2079
2080 default:
2081 if(it>=0&&it<MAXLEVELS)
2082 {
2083 return (game->lvlitems[it]&liTRIFORCE);
2084 }
2085
2086 break;
2087 }
2088
2089 return 0;
2090 }
2091
2092 case itype_map: //it: -2=any, -1=current level, other=that level
2093 {
2094
1/3
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
96 switch(it)
2095 {
2096 case -2:
2097 {
2098 for(int32_t i=0; i<MAXLEVELS; i++)
2099 {
2100 if(game->lvlitems[i]&liMAP)
2101 {
2102 return true;
2103 }
2104 }
2105
2106 return false;
2107 }
2108
2109 case -1:
2110 return (game->lvlitems[dlevel]&liMAP)!=0;
2111
2112 default:
2113
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(it>=0&&it<MAXLEVELS)
2114 {
2115 96 return (game->lvlitems[it]&liMAP)!=0;
2116 }
2117
2118 break;
2119 }
2120
2121 return 0;
2122 }
2123
2124 case itype_compass: //it: -2=any, -1=current level, other=that level
2125 {
2126
1/3
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
96 switch(it)
2127 {
2128 case -2:
2129 {
2130 for(int32_t i=0; i<MAXLEVELS; i++)
2131 {
2132 if(game->lvlitems[i]&liCOMPASS)
2133 {
2134 return true;
2135 }
2136 }
2137
2138 return false;
2139 }
2140
2141 case -1:
2142 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2143
2144 default:
2145
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(it>=0&&it<MAXLEVELS)
2146 {
2147 96 return (game->lvlitems[it]&liCOMPASS)!=0;
2148 }
2149
2150 break;
2151 }
2152 return 0;
2153 }
2154
2155 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2156 {
2157
1/3
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
96 switch(it)
2158 {
2159 case -2:
2160 {
2161 for(int32_t i=0; i<MAXLEVELS; i++)
2162 {
2163 if(game->lvlitems[i]&liBOSSKEY)
2164 {
2165 return true;
2166 }
2167 }
2168
2169 return false;
2170 }
2171
2172 case -1:
2173 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2174
2175 default:
2176
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(it>=0&&it<MAXLEVELS)
2177 {
2178 96 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2179 }
2180 break;
2181 }
2182 return 0;
2183 }
2184
2185 default:
2186 //it=(1<<(it-1));
2187 /*if (item_type>=itype_max)
2188 {
2189 system_pal();
2190 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2191 game_pal();
2192
2193 return false;
2194 }*/
2195 int32_t itemid = getItemID(itemsbuf, item_type, it);
2196
2197 if(itemid == -1)
2198 return false;
2199
2200 return game->get_item(itemid);
2201 }
2202 1531 }
2203
2204
2205 21719 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2206 {
2207
9/9
✓ Branch 0 taken 1243 times.
✓ Branch 1 taken 11775 times.
✓ Branch 2 taken 1243 times.
✓ Branch 3 taken 1243 times.
✓ Branch 4 taken 1243 times.
✓ Branch 5 taken 1243 times.
✓ Branch 6 taken 1243 times.
✓ Branch 7 taken 1243 times.
✓ Branch 8 taken 1243 times.
21719 switch(item_type)
2208 {
2209 case itype_clock:
2210 {
2211 1243 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2212
2213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1243 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1243 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2214 return itemsbuf[maxid].fam_type;
2215
2216 1243 return has_item(itype_clock,1) ? 1 : 0;
2217 }
2218
2219 case itype_key:
2220 1243 return game->get_keys();
2221
2222 case itype_lkey:
2223 1243 return game->lvlkeys[get_dlevel()];
2224
2225 case itype_magiccontainer:
2226 1243 return game->get_maxmagic()/game->get_mp_per_block();
2227
2228 case itype_triforcepiece:
2229 {
2230 1243 int32_t count=0;
2231
2232
2/2
✓ Branch 0 taken 636416 times.
✓ Branch 1 taken 1243 times.
637659 for(int32_t i=0; i<MAXLEVELS; i++)
2233 {
2234 636416 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2235 636416 }
2236
2237 1243 return count;
2238 }
2239
2240 case itype_map:
2241 {
2242 1243 int32_t count=0;
2243
2244
2/2
✓ Branch 0 taken 636416 times.
✓ Branch 1 taken 1243 times.
637659 for(int32_t i=0; i<MAXLEVELS; i++)
2245 {
2246 636416 count+=(game->lvlitems[i]&liMAP)?1:0;
2247 636416 }
2248
2249 1243 return count;
2250 }
2251
2252 case itype_compass:
2253 {
2254 1243 int32_t count=0;
2255
2256
2/2
✓ Branch 0 taken 636416 times.
✓ Branch 1 taken 1243 times.
637659 for(int32_t i=0; i<MAXLEVELS; i++)
2257 {
2258 636416 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2259 636416 }
2260
2261 1243 return count;
2262 }
2263
2264 case itype_bosskey:
2265 {
2266 1243 int32_t count=0;
2267
2268
2/2
✓ Branch 0 taken 636416 times.
✓ Branch 1 taken 1243 times.
637659 for(int32_t i=0; i<MAXLEVELS; i++)
2269 {
2270 636416 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2271 636416 }
2272
2273 1243 return count;
2274 }
2275
2276 default:
2277 11775 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2278
2279
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 11499 times.
11775 if(maxid == -1)
2280 11499 return 0;
2281
2282 276 return itemsbuf[maxid].fam_type;
2283 }
2284 21719 }
2285
2286 19831 int32_t current_item(int32_t item_type) //item currently being used
2287 {
2288 19831 return current_item(item_type, true);
2289 }
2290
2291 11 std::map<int32_t, int32_t> itemcache;
2292
2293 // Not actually used by anything at the moment...
2294 void removeFromItemCache(int32_t itemid)
2295 {
2296 itemcache.erase(itemid);
2297 }
2298
2299 74 void flushItemCache()
2300 {
2301 74 itemcache.clear();
2302
2303 //also fix the active subscreen if items were deleted -DD
2304
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(game != NULL)
2305 {
2306 74 verifyBothWeapons();
2307 74 load_Sitems(&QMisc);
2308 74 }
2309 74 }
2310
2311 // This is used often, so it should be as direct as possible.
2312 728503 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2313 {
2314
2/2
✓ Branch 0 taken 720889 times.
✓ Branch 1 taken 7614 times.
728503 if(jinx_check)
2315 {
2316
2/4
✓ Branch 0 taken 7614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7614 times.
✗ Branch 3 not taken.
7614 if(!(HeroSwordClk() || HeroItemClk()))
2317 7614 jinx_check = false; //not jinxed
2318 7614 }
2319
3/4
✓ Branch 0 taken 724790 times.
✓ Branch 1 taken 3713 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 724790 times.
728503 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2320 {
2321 724790 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2322
2323
2/2
✓ Branch 0 taken 687166 times.
✓ Branch 1 taken 37624 times.
724790 if(res != itemcache.end())
2324 687166 return res->second;
2325 37624 }
2326
2327 41337 int32_t result = -1;
2328 41337 int32_t highestlevel = -1;
2329
2330
2/2
✓ Branch 0 taken 10582272 times.
✓ Branch 1 taken 41337 times.
10623609 for(int32_t i=0; i<MAXITEMS; i++)
2331 {
2332
5/6
✓ Branch 0 taken 58165 times.
✓ Branch 1 taken 10524107 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 58064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 101 times.
10582272 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2333 {
2334
4/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 21 times.
101 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2335 {
2336 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2337
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2 times.
21 if(!checkmagiccost(i))
2338 {
2339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2340 }
2341 19 }
2342
1/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2343 {
2344 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2345 continue;
2346 }
2347
2348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(itemsbuf[i].fam_type >= highestlevel)
2349 {
2350 99 highestlevel = itemsbuf[i].fam_type;
2351 99 result=i;
2352 99 }
2353 99 }
2354 10582270 }
2355
2356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41337 times.
41337 if(!jinx_check) //Can't cache jinx_check results
2357 41337 itemcache[itemtype] = result;
2358 41337 return result;
2359 728503 }
2360
2361 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2362 728503 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2363 {
2364 728503 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2365
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 720889 times.
728503 if(!jinx_check) //If not already a jinx-immune-only check...
2366 {
2367 //And the player IS jinxed...
2368
2/4
✓ Branch 0 taken 720889 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 720889 times.
720889 if(HeroSwordClk() || HeroItemClk())
2369 {
2370 //Then do a jinx-immune-only check here
2371 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2372 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2373 //Should NOT need a compat rule, as this should always return -1 in old quests.
2374 if(ret2 > -1) return ret2;
2375 }
2376 720889 }
2377 728503 return ret;
2378 728503 }
2379 5469 int32_t current_item_power(int32_t itemtype)
2380 {
2381 5469 int32_t result = current_item_id(itemtype,true);
2382
2/2
✓ Branch 0 taken 5455 times.
✓ Branch 1 taken 14 times.
5469 return (result<0) ? 0 : itemsbuf[result].power;
2383 }
2384
2385 int32_t heart_container_id()
2386 {
2387 for(int32_t i=0; i<MAXITEMS; i++)
2388 {
2389 if(itemsbuf[i].family == itype_heartcontainer)
2390 {
2391 return i;
2392 }
2393 }
2394 return -1;
2395 }
2396
2397 1243 int32_t item_tile_mod()
2398 {
2399 1243 int32_t tile=0;
2400
2401
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(game->get_bombs())
2402 {
2403 int32_t itemid = current_item_id(itype_bomb,false);
2404 if(itemid > -1 && checkbunny(itemid))
2405 tile+=itemsbuf[itemid].ltm;
2406 }
2407
2408
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(game->get_sbombs())
2409 {
2410 int32_t itemid = current_item_id(itype_sbomb,false);
2411 if(itemid > -1 && checkbunny(itemid))
2412 tile+=itemsbuf[itemid].ltm;
2413 }
2414
2415
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_clock))
2416 {
2417 int32_t itemid =
2418 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2419 ? iClock
2420 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2421 if(itemid > -1 && checkbunny(itemid))
2422 tile+=itemsbuf[itemid].ltm;
2423 }
2424
2425
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_key))
2426 {
2427 int32_t itemid =
2428 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2429 ? iKey
2430 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2431 if(itemid > -1 && checkbunny(itemid))
2432 tile+=itemsbuf[itemid].ltm;
2433 }
2434
2435
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_lkey))
2436 {
2437 int32_t itemid =
2438 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2439 ? iLevelKey
2440 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2441 if(itemid > -1 && checkbunny(itemid))
2442 tile+=itemsbuf[itemid].ltm;
2443 }
2444
2445
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_map))
2446 {
2447 int32_t itemid =
2448 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2449 ? iMap
2450 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2451 if(itemid > -1 && checkbunny(itemid))
2452 tile+=itemsbuf[itemid].ltm;
2453 }
2454
2455
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_compass))
2456 {
2457 int32_t itemid =
2458 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2459 ? iCompass
2460 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2461 if(itemid > -1 && checkbunny(itemid))
2462 tile+=itemsbuf[itemid].ltm;
2463 }
2464
2465
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_bosskey))
2466 {
2467 int32_t itemid =
2468 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2469 ? iBossKey
2470 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2471 if(itemid > -1 && checkbunny(itemid))
2472 tile+=itemsbuf[itemid].ltm;
2473 }
2474
2475
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_magiccontainer))
2476 {
2477 int32_t itemid =
2478 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2479 ? iMagicC
2480 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2481 if(itemid > -1 && checkbunny(itemid))
2482 tile+=itemsbuf[itemid].ltm;
2483 }
2484
2485
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(current_item(itype_triforcepiece))
2486 {
2487 int32_t itemid =
2488 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2489 ? iTriforce
2490 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2491 if(itemid > -1 && checkbunny(itemid))
2492 tile+=itemsbuf[itemid].ltm;
2493 }
2494
2495
2/2
✓ Branch 0 taken 1243 times.
✓ Branch 1 taken 636416 times.
637659 for(int32_t i=0; i<itype_max; i++)
2496 {
2497
1/2
✓ Branch 0 taken 636416 times.
✗ Branch 1 not taken.
636416 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2498 {
2499 switch(i)
2500 {
2501 case itype_bomb:
2502 case itype_sbomb:
2503 case itype_clock:
2504 case itype_key:
2505 case itype_lkey:
2506 case itype_map:
2507 case itype_compass:
2508 case itype_bosskey:
2509 case itype_magiccontainer:
2510 case itype_triforcepiece:
2511 continue; //already handled
2512 }
2513 }
2514 636416 int32_t itemid = current_item_id(i,false);
2515
2/2
✓ Branch 0 taken 635173 times.
✓ Branch 1 taken 1243 times.
636416 if(i == itype_shield)
2516 1243 itemid = getCurrentShield(false);
2517
2518
3/4
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 633977 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439 times.
636416 if(itemid < 0 || !checkbunny(itemid))
2519 633977 continue;
2520
2521 2439 itemdata const& itm = itemsbuf[itemid];
2522
2523
2/2
✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 1243 times.
2439 switch(itm.family)
2524 {
2525 case itype_shield:
2526
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 if(itm.flags & ITEM_FLAG9) //active shield
2527 {
2528 if(!usingActiveShield(itemid))
2529 {
2530 tile+=itm.misc6; //'Inactive PTM'
2531 continue;
2532 }
2533 }
2534 1243 break;
2535 }
2536
2537 2439 tile+=itm.ltm;
2538 2439 }
2539
2540 1243 return tile;
2541 }
2542
2543 1243 int32_t bunny_tile_mod()
2544 {
2545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1243 times.
1243 if(Hero.BunnyClock())
2546 {
2547 return game->get_bunny_ltm();
2548 }
2549 1243 return 0;
2550 1243 }
2551
2552 // Hints are drawn on a separate layer to combo reveals.
2553 void draw_lens_under(BITMAP *dest, bool layer)
2554 {
2555 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2556 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2557 //Lens flag 3: Don't show armos/chest/dive items
2558 //Lens flag 4: Show Raft Paths
2559 //Lens flag 5: Show Invisible Enemies
2560 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2561
2562 int32_t strike_hint_table[11]=
2563 {
2564 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2565 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2566 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2567 };
2568
2569 // int32_t page = tmpscr->cpage;
2570 {
2571 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2572 // int32_t temptimer=0;
2573 int32_t tempitem, tempweapon=0;
2574 strike_hint=strike_hint_table[strike_hint_counter];
2575
2576 if(strike_hint_timer>32)
2577 {
2578 strike_hint_timer=0;
2579 strike_hint_counter=((strike_hint_counter+1)%11);
2580 }
2581
2582 ++strike_hint_timer;
2583
2584 for(int32_t i=0; i<176; i++)
2585 {
2586 int32_t x = (i & 15) << 4;
2587 int32_t y = (i & 0xF0) + playing_field_offset;
2588 int32_t tempitemx=-16, tempitemy=-16;
2589 int32_t tempweaponx=-16, tempweapony=-16;
2590
2591 for(int32_t iter=0; iter<2; ++iter)
2592 {
2593 int32_t checkflag=0;
2594
2595 if(iter==0)
2596 {
2597 checkflag=combobuf[tmpscr->data[i]].flag;
2598 }
2599 else
2600 {
2601 checkflag=tmpscr->sflag[i];
2602 }
2603
2604 if(checkflag==mfSTRIKE)
2605 {
2606 if(!hints)
2607 {
2608 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2609 }
2610 else
2611 {
2612 checkflag = strike_hint;
2613 }
2614 }
2615
2616 switch(checkflag)
2617 {
2618 case 0:
2619 case mfZELDA:
2620 case mfPUSHED:
2621 case mfENEMY0:
2622 case mfENEMY1:
2623 case mfENEMY2:
2624 case mfENEMY3:
2625 case mfENEMY4:
2626 case mfENEMY5:
2627 case mfENEMY6:
2628 case mfENEMY7:
2629 case mfENEMY8:
2630 case mfENEMY9:
2631 case mfSINGLE:
2632 case mfSINGLE16:
2633 case mfNOENEMY:
2634 case mfTRAP_H:
2635 case mfTRAP_V:
2636 case mfTRAP_4:
2637 case mfTRAP_LR:
2638 case mfTRAP_UD:
2639 case mfNOGROUNDENEMY:
2640 case mfNOBLOCKS:
2641 case mfSCRIPT1:
2642 case mfSCRIPT2:
2643 case mfSCRIPT3:
2644 case mfSCRIPT4:
2645 case mfSCRIPT5:
2646 case mfSCRIPT6:
2647 case mfSCRIPT7:
2648 case mfSCRIPT8:
2649 case mfSCRIPT9:
2650 case mfSCRIPT10:
2651 case mfSCRIPT11:
2652 case mfSCRIPT12:
2653 case mfSCRIPT13:
2654 case mfSCRIPT14:
2655 case mfSCRIPT15:
2656 case mfSCRIPT16:
2657 case mfSCRIPT17:
2658 case mfSCRIPT18:
2659 case mfSCRIPT19:
2660 case mfSCRIPT20:
2661 case mfPITHOLE:
2662 case mfPITFALLFLOOR:
2663 case mfLAVA:
2664 case mfICE:
2665 case mfICEDAMAGE:
2666 case mfDAMAGE1:
2667 case mfDAMAGE2:
2668 case mfDAMAGE4:
2669 case mfDAMAGE8:
2670 case mfDAMAGE16:
2671 case mfDAMAGE32:
2672 case mfFREEZEALL:
2673 case mfFREZEALLANSFFCS:
2674 case mfFREEZEFFCSOLY:
2675 case mfSCRITPTW1TRIG:
2676 case mfSCRITPTW2TRIG:
2677 case mfSCRITPTW3TRIG:
2678 case mfSCRITPTW4TRIG:
2679 case mfSCRITPTW5TRIG:
2680 case mfSCRITPTW6TRIG:
2681 case mfSCRITPTW7TRIG:
2682 case mfSCRITPTW8TRIG:
2683 case mfSCRITPTW9TRIG:
2684 case mfSCRITPTW10TRIG:
2685 case mfTROWEL:
2686 case mfTROWELNEXT:
2687 case mfTROWELSPECIALITEM:
2688 case mfSLASHPOT:
2689 case mfLIFTPOT:
2690 case mfLIFTORSLASH:
2691 case mfLIFTROCK:
2692 case mfLIFTROCKHEAVY:
2693 case mfDROPITEM:
2694 case mfSPECIALITEM:
2695 case mfDROPKEY:
2696 case mfDROPLKEY:
2697 case mfDROPCOMPASS:
2698 case mfDROPMAP:
2699 case mfDROPBOSSKEY:
2700 case mfSPAWNNPC:
2701 case mfSWITCHHOOK:
2702 case mfSIDEVIEWLADDER:
2703 case mfSIDEVIEWPLATFORM:
2704 case mfNOENEMYSPAWN:
2705 case mfENEMYALL:
2706 case mfNOMIRROR:
2707 case mfUNSAFEGROUND:
2708 case mf168:
2709 case mf169:
2710 case mf170:
2711 case mf171:
2712 case mf172:
2713 case mf173:
2714 case mf174:
2715 case mf175:
2716 case mf176:
2717 case mf177:
2718 case mf178:
2719 case mf179:
2720 case mf180:
2721 case mf181:
2722 case mf182:
2723 case mf183:
2724 case mf184:
2725 case mf185:
2726 case mf186:
2727 case mf187:
2728 case mf188:
2729 case mf189:
2730 case mf190:
2731 case mf191:
2732 case mf192:
2733 case mf193:
2734 case mf194:
2735 case mf195:
2736 case mf196:
2737 case mf197:
2738 case mf198:
2739 case mf199:
2740 case mf200:
2741 case mf201:
2742 case mf202:
2743 case mf203:
2744 case mf204:
2745 case mf205:
2746 case mf206:
2747 case mf207:
2748 case mf208:
2749 case mf209:
2750 case mf210:
2751 case mf211:
2752 case mf212:
2753 case mf213:
2754 case mf214:
2755 case mf215:
2756 case mf216:
2757 case mf217:
2758 case mf218:
2759 case mf219:
2760 case mf220:
2761 case mf221:
2762 case mf222:
2763 case mf223:
2764 case mf224:
2765 case mf225:
2766 case mf226:
2767 case mf227:
2768 case mf228:
2769 case mf229:
2770 case mf230:
2771 case mf231:
2772 case mf232:
2773 case mf233:
2774 case mf234:
2775 case mf235:
2776 case mf236:
2777 case mf237:
2778 case mf238:
2779 case mf239:
2780 case mf240:
2781 case mf241:
2782 case mf242:
2783 case mf243:
2784 case mf244:
2785 case mf245:
2786 case mf246:
2787 case mf247:
2788 case mf248:
2789 case mf249:
2790 case mf250:
2791 case mf251:
2792 case mf252:
2793 case mf253:
2794 case mf254:
2795 case mfEXTENDED:
2796 break;
2797
2798 case mfPUSHUD:
2799 case mfPUSHLR:
2800 case mfPUSH4:
2801 case mfPUSHU:
2802 case mfPUSHD:
2803 case mfPUSHL:
2804 case mfPUSHR:
2805 case mfPUSHUDNS:
2806 case mfPUSHLRNS:
2807 case mfPUSH4NS:
2808 case mfPUSHUNS:
2809 case mfPUSHDNS:
2810 case mfPUSHLNS:
2811 case mfPUSHRNS:
2812 case mfPUSHUDINS:
2813 case mfPUSHLRINS:
2814 case mfPUSH4INS:
2815 case mfPUSHUINS:
2816 case mfPUSHDINS:
2817 case mfPUSHLINS:
2818 case mfPUSHRINS:
2819 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2820 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2821 {
2822 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2823 }
2824
2825 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2826 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2827 {
2828 if(hints)
2829 {
2830 switch(combobuf[tmpscr->data[i]].type)
2831 {
2832 case cPUSH_HEAVY:
2833 case cPUSH_HW:
2834 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2835 tempitemx=x, tempitemy=y;
2836
2837 if(tempitem>-1)
2838 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2839
2840 break;
2841
2842 case cPUSH_HEAVY2:
2843 case cPUSH_HW2:
2844 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2845 tempitemx=x, tempitemy=y;
2846
2847 if(tempitem>-1)
2848 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2849
2850 break;
2851 }
2852 }
2853 }
2854
2855 break;
2856
2857 case mfWHISTLE:
2858 if(hints)
2859 {
2860 tempitem=getItemID(itemsbuf,itype_whistle,1);
2861
2862 if(tempitem<0) break;
2863
2864 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2865 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2866 {
2867 tempitemx=x;
2868 tempitemy=y;
2869 }
2870
2871 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2872 }
2873
2874 break;
2875
2876 //Why is this here?
2877 case mfFAIRY:
2878 case mfMAGICFAIRY:
2879 case mfALLFAIRY:
2880 if(hints)
2881 {
2882 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2883
2884 if(tempitem < 0) break;
2885
2886 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2887 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2888 {
2889 tempitemx=x;
2890 tempitemy=y;
2891 }
2892
2893 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2894 }
2895
2896 break;
2897
2898 case mfBCANDLE:
2899 if(!hints)
2900 {
2901 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2902 }
2903 else
2904 {
2905 tempitem=getItemID(itemsbuf,itype_candle,1);
2906
2907 if(tempitem<0) break;
2908
2909 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2910 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2911 {
2912 tempitemx=x;
2913 tempitemy=y;
2914 }
2915
2916 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2917 }
2918
2919 break;
2920
2921 case mfRCANDLE:
2922 if(!hints)
2923 {
2924 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2925 }
2926 else
2927 {
2928 tempitem=getItemID(itemsbuf,itype_candle,2);
2929
2930 if(tempitem<0) break;
2931
2932 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2933 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2934 {
2935 tempitemx=x;
2936 tempitemy=y;
2937 }
2938
2939 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2940 }
2941
2942 break;
2943
2944 case mfWANDFIRE:
2945 if(!hints)
2946 {
2947 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2948 }
2949 else
2950 {
2951 tempitem=getItemID(itemsbuf,itype_wand,1);
2952
2953 if(tempitem<0) break;
2954
2955 tempweapon=wFire;
2956
2957 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2958 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2959 {
2960 tempitemx=x;
2961 tempitemy=y;
2962 }
2963 else
2964 {
2965 tempweaponx=x;
2966 tempweapony=y;
2967 }
2968
2969 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2970 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2971 }
2972
2973 break;
2974
2975 case mfDINSFIRE:
2976 if(!hints)
2977 {
2978 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2979 }
2980 else
2981 {
2982 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2983
2984 if(tempitem<0) break;
2985
2986 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2987 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2988 {
2989 tempitemx=x;
2990 tempitemy=y;
2991 }
2992
2993 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2994 }
2995
2996 break;
2997
2998 case mfARROW:
2999 if(!hints)
3000 {
3001 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3002 }
3003 else
3004 {
3005 tempitem=getItemID(itemsbuf,itype_arrow,1);
3006
3007 if(tempitem<0) break;
3008
3009 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3010 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3011 {
3012 tempitemx=x;
3013 tempitemy=y;
3014 }
3015
3016 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3017 }
3018
3019 break;
3020
3021 case mfSARROW:
3022 if(!hints)
3023 {
3024 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3025 }
3026 else
3027 {
3028 tempitem=getItemID(itemsbuf,itype_arrow,2);
3029
3030 if(tempitem<0) break;
3031
3032 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3033 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3034 {
3035 tempitemx=x;
3036 tempitemy=y;
3037 }
3038
3039 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3040 }
3041
3042 break;
3043
3044 case mfGARROW:
3045 if(!hints)
3046 {
3047 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3048 }
3049 else
3050 {
3051 tempitem=getItemID(itemsbuf,itype_arrow,3);
3052
3053 if(tempitem<0) break;
3054
3055 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3056 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3057 {
3058 tempitemx=x;
3059 tempitemy=y;
3060 }
3061
3062 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3063 }
3064
3065 break;
3066
3067 case mfBOMB:
3068 if(!hints)
3069 {
3070 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3071 }
3072 else
3073 {
3074 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3075 tempweapon = wLitBomb;
3076
3077 //if (tempitem<0) break;
3078 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3079 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3080 {
3081 tempweaponx=x;
3082 tempweapony=y;
3083 }
3084
3085 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3086 }
3087
3088 break;
3089
3090 case mfSBOMB:
3091 if(!hints)
3092 {
3093 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3094 }
3095 else
3096 {
3097 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3098 //if (tempitem<0) break;
3099 tempweapon = wLitSBomb;
3100
3101 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3102 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3103 {
3104 tempweaponx=x;
3105 tempweapony=y;
3106 }
3107
3108 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3109 }
3110
3111 break;
3112
3113 case mfARMOS_SECRET:
3114 if(!hints)
3115 {
3116 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3117 }
3118 break;
3119
3120 case mfBRANG:
3121 if(!hints)
3122 {
3123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3124 }
3125 else
3126 {
3127 tempitem=getItemID(itemsbuf,itype_brang,1);
3128
3129 if(tempitem<0) break;
3130
3131 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3132 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3133 {
3134 tempitemx=x;
3135 tempitemy=y;
3136 }
3137
3138 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3139 }
3140
3141 break;
3142
3143 case mfMBRANG:
3144 if(!hints)
3145 {
3146 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3147 }
3148 else
3149 {
3150 tempitem=getItemID(itemsbuf,itype_brang,2);
3151
3152 if(tempitem<0) break;
3153
3154 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3155 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3156 {
3157 tempitemx=x;
3158 tempitemy=y;
3159 }
3160
3161 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3162 }
3163
3164 break;
3165
3166 case mfFBRANG:
3167 if(!hints)
3168 {
3169 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3170 }
3171 else
3172 {
3173 tempitem=getItemID(itemsbuf,itype_brang,3);
3174
3175 if(tempitem<0) break;
3176
3177 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3178 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3179 {
3180 tempitemx=x;
3181 tempitemy=y;
3182 }
3183
3184 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3185 }
3186
3187 break;
3188
3189 case mfWANDMAGIC:
3190 if(!hints)
3191 {
3192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3193 }
3194 else
3195 {
3196 tempitem=getItemID(itemsbuf,itype_wand,1);
3197
3198 if(tempitem<0) break;
3199
3200 tempweapon=itemsbuf[tempitem].wpn3;
3201
3202 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3203 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3204 {
3205 tempitemx=x;
3206 tempitemy=y;
3207 }
3208 else
3209 {
3210 tempweaponx=x;
3211 tempweapony=y;
3212 --lens_hint_weapon[wMagic][4];
3213
3214 if(lens_hint_weapon[wMagic][4]<-8)
3215 {
3216 lens_hint_weapon[wMagic][4]=8;
3217 }
3218 }
3219
3220 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3221 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3222 }
3223
3224 break;
3225
3226 case mfREFMAGIC:
3227 if(!hints)
3228 {
3229 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3230 }
3231 else
3232 {
3233 tempitem=getItemID(itemsbuf,itype_shield,3);
3234
3235 if(tempitem<0) break;
3236
3237 tempweapon=ewMagic;
3238
3239 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3240 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3241 {
3242 tempitemx=x;
3243 tempitemy=y;
3244 }
3245 else
3246 {
3247 tempweaponx=x;
3248 tempweapony=y;
3249
3250 if(lens_hint_weapon[ewMagic][2]==up)
3251 {
3252 --lens_hint_weapon[ewMagic][4];
3253 }
3254 else
3255 {
3256 ++lens_hint_weapon[ewMagic][4];
3257 }
3258
3259 if(lens_hint_weapon[ewMagic][4]>8)
3260 {
3261 lens_hint_weapon[ewMagic][2]=up;
3262 }
3263
3264 if(lens_hint_weapon[ewMagic][4]<=0)
3265 {
3266 lens_hint_weapon[ewMagic][2]=down;
3267 }
3268 }
3269
3270 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3271 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3272 }
3273
3274 break;
3275
3276 case mfREFFIREBALL:
3277 if(!hints)
3278 {
3279 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3280 }
3281 else
3282 {
3283 tempitem=getItemID(itemsbuf,itype_shield,3);
3284
3285 if(tempitem<0) break;
3286
3287 tempweapon=ewFireball;
3288
3289 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3290 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3291 {
3292 tempitemx=x;
3293 tempitemy=y;
3294 tempweaponx=x;
3295 tempweapony=y;
3296 ++lens_hint_weapon[ewFireball][3];
3297
3298 if(lens_hint_weapon[ewFireball][3]>8)
3299 {
3300 lens_hint_weapon[ewFireball][3]=-8;
3301 lens_hint_weapon[ewFireball][4]=8;
3302 }
3303
3304 if(lens_hint_weapon[ewFireball][3]>0)
3305 {
3306 ++lens_hint_weapon[ewFireball][4];
3307 }
3308 else
3309 {
3310 --lens_hint_weapon[ewFireball][4];
3311 }
3312 }
3313
3314 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3315 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3316 }
3317
3318 break;
3319
3320 case mfSWORD:
3321 if(!hints)
3322 {
3323 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3324 }
3325 else
3326 {
3327 tempitem=getItemID(itemsbuf,itype_sword,1);
3328
3329 if(tempitem<0) break;
3330
3331 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3332 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3333 {
3334 tempitemx=x;
3335 tempitemy=y;
3336 }
3337
3338 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3339 }
3340
3341 break;
3342
3343 case mfWSWORD:
3344 if(!hints)
3345 {
3346 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3347 }
3348 else
3349 {
3350 tempitem=getItemID(itemsbuf,itype_sword,2);
3351
3352 if(tempitem<0) break;
3353
3354 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3355 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3356 {
3357 tempitemx=x;
3358 tempitemy=y;
3359 }
3360
3361 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3362 }
3363
3364 break;
3365
3366 case mfMSWORD:
3367 if(!hints)
3368 {
3369 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3370 }
3371 else
3372 {
3373 tempitem=getItemID(itemsbuf,itype_sword,3);
3374
3375 if(tempitem<0) break;
3376
3377 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3378 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3379 {
3380 tempitemx=x;
3381 tempitemy=y;
3382 }
3383
3384 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3385 }
3386
3387 break;
3388
3389 case mfXSWORD:
3390 if(!hints)
3391 {
3392 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3393 }
3394 else
3395 {
3396 tempitem=getItemID(itemsbuf,itype_sword,4);
3397
3398 if(tempitem<0) break;
3399
3400 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3401 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3402 {
3403 tempitemx=x;
3404 tempitemy=y;
3405 }
3406
3407 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3408 }
3409
3410 break;
3411
3412 case mfSWORDBEAM:
3413 if(!hints)
3414 {
3415 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3416 }
3417 else
3418 {
3419 tempitem=getItemID(itemsbuf,itype_sword,1);
3420
3421 if(tempitem<0) break;
3422
3423 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3424 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3425 {
3426 tempitemx=x;
3427 tempitemy=y;
3428 }
3429
3430 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3431 }
3432
3433 break;
3434
3435 case mfWSWORDBEAM:
3436 if(!hints)
3437 {
3438 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3439 }
3440 else
3441 {
3442 tempitem=getItemID(itemsbuf,itype_sword,2);
3443
3444 if(tempitem<0) break;
3445
3446 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3447 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3448 {
3449 tempitemx=x;
3450 tempitemy=y;
3451 }
3452
3453 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3454 }
3455
3456 break;
3457
3458 case mfMSWORDBEAM:
3459 if(!hints)
3460 {
3461 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3462 }
3463 else
3464 {
3465 tempitem=getItemID(itemsbuf,itype_sword,3);
3466
3467 if(tempitem<0) break;
3468
3469 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3470 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3471 {
3472 tempitemx=x;
3473 tempitemy=y;
3474 }
3475
3476 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3477 }
3478
3479 break;
3480
3481 case mfXSWORDBEAM:
3482 if(!hints)
3483 {
3484 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3485 }
3486 else
3487 {
3488 tempitem=getItemID(itemsbuf,itype_sword,4);
3489
3490 if(tempitem<0) break;
3491
3492 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3493 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3494 {
3495 tempitemx=x;
3496 tempitemy=y;
3497 }
3498
3499 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3500 }
3501
3502 break;
3503
3504 case mfHOOKSHOT:
3505 if(!hints)
3506 {
3507 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3508 }
3509 else
3510 {
3511 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3512
3513 if(tempitem<0) break;
3514
3515 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3516 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3517 {
3518 tempitemx=x;
3519 tempitemy=y;
3520 }
3521
3522 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3523 }
3524
3525 break;
3526
3527 case mfWAND:
3528 if(!hints)
3529 {
3530 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3531 }
3532 else
3533 {
3534 tempitem=getItemID(itemsbuf,itype_wand,1);
3535
3536 if(tempitem<0) break;
3537
3538 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3539 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3540 {
3541 tempitemx=x;
3542 tempitemy=y;
3543 }
3544
3545 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3546 }
3547
3548 break;
3549
3550 case mfHAMMER:
3551 if(!hints)
3552 {
3553 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3554 }
3555 else
3556 {
3557 tempitem=getItemID(itemsbuf,itype_hammer,1);
3558
3559 if(tempitem<0) break;
3560
3561 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3562 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3563 {
3564 tempitemx=x;
3565 tempitemy=y;
3566 }
3567
3568 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3569 }
3570
3571 break;
3572
3573 case mfARMOS_ITEM:
3574 case mfDIVE_ITEM:
3575 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3576 {
3577 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3578 }
3579 break;
3580
3581 case 16:
3582 case 17:
3583 case 18:
3584 case 19:
3585 case 20:
3586 case 21:
3587 case 22:
3588 case 23:
3589 case 24:
3590 case 25:
3591 case 26:
3592 case 27:
3593 case 28:
3594 case 29:
3595 case 30:
3596 case 31:
3597 if(!hints)
3598 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3599 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3600
3601 break;
3602 case mfSECRETSNEXT:
3603 if(!hints)
3604 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3605 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3606
3607 break;
3608
3609 case mfSTRIKE:
3610 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3611 {
3612 goto special;
3613 }
3614 else
3615 {
3616 break;
3617 }
3618
3619 default: goto special;
3620
3621 special:
3622 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3623 {
3624 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3625 {
3626 rectfill(dest,x,y,x+15,y+15,WHITE);
3627 }
3628 }
3629
3630 break;
3631 }
3632 }
3633 }
3634
3635 if(layer)
3636 {
3637 if(tmpscr->door[0]==dWALK)
3638 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3639
3640 if(tmpscr->door[1]==dWALK)
3641 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3642
3643 if(tmpscr->door[2]==dWALK)
3644 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3645
3646 if(tmpscr->door[3]==dWALK)
3647 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3648
3649 if(tmpscr->door[0]==dBOMB)
3650 {
3651 showbombeddoor(dest, 0);
3652 }
3653
3654 if(tmpscr->door[1]==dBOMB)
3655 {
3656 showbombeddoor(dest, 1);
3657 }
3658
3659 if(tmpscr->door[2]==dBOMB)
3660 {
3661 showbombeddoor(dest, 2);
3662 }
3663
3664 if(tmpscr->door[3]==dBOMB)
3665 {
3666 showbombeddoor(dest, 3);
3667 }
3668 }
3669
3670 if(tmpscr->stairx + tmpscr->stairy)
3671 {
3672 if(!hints)
3673 {
3674 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3675 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3676 }
3677 else
3678 {
3679 if(tmpscr->flags&fWHISTLE)
3680 {
3681 tempitem=getItemID(itemsbuf,itype_whistle,1);
3682 int32_t tempitemx=-16;
3683 int32_t tempitemy=-16;
3684
3685 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3686 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3687 {
3688 tempitemx=tmpscr->stairx;
3689 tempitemy=tmpscr->stairy+playing_field_offset;
3690 }
3691
3692 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3693 }
3694 }
3695 }
3696 }
3697 }
3698
3699 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3700
3701 void draw_lens_over()
3702 {
3703 // Oh, what the heck.
3704 static BITMAP *lens_scr = NULL;
3705 static int32_t last_width = -1;
3706 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3707
3708 // Only redraw the circle if the size has changed
3709 if(width != last_width)
3710 {
3711 if(lens_scr == NULL)
3712 {
3713 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3714 }
3715
3716 clear_to_color(lens_scr, BLACK);
3717 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3718 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3719 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3720 last_width=width;
3721 }
3722
3723 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3724 }
3725
3726 //----------------------------------------------------------------
3727
3728 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3729 {
3730 //recreating a big bitmap every frame is highly sluggish.
3731 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3732 clear_to_color(wavebuf, BLACK);
3733 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3734
3735 int32_t ofs;
3736 // int32_t amplitude=8;
3737 // int32_t wavelength=4;
3738 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3739 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3740 int32_t amp2=168;
3741 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3742 int32_t i=frame%amp2;
3743
3744 for(int32_t j=0; j<168; j++)
3745 {
3746 if(j&1 && interpol)
3747 {
3748 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3749 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3750 }
3751 else
3752 {
3753 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3754 }
3755
3756 if(ofs)
3757 {
3758 for(int32_t k=0; k<256; k++)
3759 {
3760 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3761 }
3762 }
3763 }
3764 }
3765
3766 void draw_fuzzy(int32_t fuzz)
3767 // draws from right half of scrollbuf to framebuf
3768 {
3769 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3770 byte *start, *si, *di;
3771
3772 if(fuzz<1)
3773 fuzz = 1;
3774
3775 xstep = 128%fuzz;
3776
3777 if(xstep > 0)
3778 xstep = fuzz-xstep;
3779
3780 ystep = 112%fuzz;
3781
3782 if(ystep > 0)
3783 ystep = fuzz-ystep;
3784
3785 firsty = 1;
3786
3787 for(y=0; y<224;)
3788 {
3789 start = &(scrollbuf->line[y][256]);
3790
3791 for(dy=0; dy<ystep && dy+y<224; dy++)
3792 {
3793 si = start;
3794 di = &(framebuf->line[y+dy][0]);
3795 i = xstep;
3796 firstx = 1;
3797
3798 for(dx=0; dx<256; dx++)
3799 {
3800 *(di++) = *si;
3801
3802 if(++i >= fuzz)
3803 {
3804 if(!firstx)
3805 si += fuzz;
3806 else
3807 {
3808 si += fuzz-xstep;
3809 firstx = 0;
3810 }
3811
3812 i = 0;
3813 }
3814 }
3815 }
3816
3817 if(!firsty)
3818 y += fuzz;
3819 else
3820 {
3821 y += ystep;
3822 ystep = fuzz;
3823 firsty = 0;
3824 }
3825 }
3826 }
3827
3828 3132 void updatescr(bool allowwavy)
3829 {
3830
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3132 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3831
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
3132 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3832
3833
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(toogam)
3834 {
3835 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3836 }
3837
3838
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(Showpal)
3839 dump_pal(framebuf);
3840
3841
2/2
✓ Branch 0 taken 2681 times.
✓ Branch 1 taken 451 times.
3132 if(!Playing)
3842 451 black_opening_count=0;
3843
3844
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(black_opening_count<0) //shape is opening up
3845 {
3846 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3847
3848 if(Advance||(!Paused))
3849 {
3850 ++black_opening_count;
3851 }
3852 }
3853
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 else if(black_opening_count>0) //shape is closing
3854 {
3855 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3856
3857 if(Advance||(!Paused))
3858 {
3859 --black_opening_count;
3860 }
3861 }
3862
3863
2/4
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3132 times.
✗ Branch 3 not taken.
3132 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3864 {
3865 black_opening_shape = bosCIRCLE;
3866 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3867 refreshTints();
3868 refreshpal=true;
3869 }
3870
3871
2/2
✓ Branch 0 taken 3122 times.
✓ Branch 1 taken 10 times.
3132 if(refreshpal)
3872 {
3873 10 refreshpal=false;
3874 10 RAMpal[253] = _RGB(0,0,0);
3875 10 RAMpal[254] = _RGB(63,63,63);
3876 10 hw_palette = &RAMpal;
3877 10 update_hw_pal = true;
3878
3879 10 create_rgb_table(&rgb_table, RAMpal, NULL);
3880 10 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3881 10 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3882
3883
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t q=0; q<PAL_SIZE; q++)
3884 {
3885 2560 trans_table2.data[0][q] = q;
3886 2560 trans_table2.data[q][q] = q;
3887 2560 }
3888 10 }
3889
3890
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(details)
3891 show_details();
3892
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(show_ff_scripts)
3893 show_ffscript_names();
3894
3895 3132 bool clearwavy = (wavy <= 0);
3896
3897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if(wavy <= 0)
3898 {
3899 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3900 3132 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3901 3132 }
3902
3903 3132 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3904
3905
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3132 if(wavy && Playing && allowwavy)
3906 {
3907 draw_wavy(framebuf, wavybuf, wavy,false);
3908 }
3909
3910
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(clearwavy)
3911 3132 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3912 else if(Playing && !Paused)
3913 wavy--; // Wavy was set by a script. Decrement it.
3914
3915
5/6
✓ Branch 0 taken 2681 times.
✓ Branch 1 taken 451 times.
✓ Branch 2 taken 270 times.
✓ Branch 3 taken 2411 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 270 times.
3132 if(Playing && msgpos && !screenscrolling)
3916 {
3917
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!(msg_bg_display_buf->clip))
3918 270 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3919
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!(msg_portrait_display_buf->clip))
3920 270 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3921
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!(msg_txt_display_buf->clip))
3922 270 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3923 270 }
3924
3925 /*
3926 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3927 {
3928 BITMAP* subBmp = 0;
3929 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3930 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3931 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3932 destroy_bitmap(subBmp);
3933 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3934 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3935 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3936 }
3937 */
3938
3939
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3940
3941
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(nosubscr)
3942 {
3943 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3944 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3945 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3946 }
3947
3948 //TODO: Optimize blit 'overcalls' -Gleeok
3949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 BITMAP *source = nosubscr ? panorama : wavybuf;
3950
3951 static BITMAP *scanlinesbmp=NULL;
3952
3953
4/8
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3132 times.
✓ Branch 4 taken 3132 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3132 times.
3132 if(resx != SCREEN_W || resy != SCREEN_H)
3954 {
3955 Z_message("Conflicting variables warning: screen_scale %i, resx %i, resy %i, w %i, h %i\n", screen_scale, resx, resy, SCREEN_W, SCREEN_H);
3956 resx = SCREEN_W;
3957 resy = SCREEN_H;
3958 screen_scale = zc_max(zc_min(resx / 320, resy / 240), 1);
3959 }
3960
3961
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3132 if(!sbig && screen_scale > 1)
3962 sbig = true;
3963
3964 3132 const int32_t sx = 256 * screen_scale;
3965 3132 const int32_t sy = 224 * screen_scale;
3966 3132 const int32_t scale_mul = screen_scale - 1;
3967 3132 const int32_t mx = scale_mul * 128;
3968 3132 const int32_t my = scale_mul * 112;
3969
3970
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(sbig)
3971 {
3972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if(scanlines)
3973 {
3974 if(!scanlinesbmp)
3975 scanlinesbmp = create_bitmap_ex(8, sx, sy);
3976
3977 stretch_blit(source, scanlinesbmp, 0, 0, 256, 224, 0, 0, sx, sy);
3978
3979 for(int32_t i=0; i<224; ++i)
3980 _allegro_hline(scanlinesbmp, 0, (i*screen_scale)+1, sx, BLACK);
3981
3982 blit(scanlinesbmp, screen, 0, 0, scrx+32-mx, scry+8-my, sx, sy);
3983 }
3984 else
3985 {
3986 3132 stretch_blit(source, screen, 0, 0, 256, 224, scrx+32-mx, scry+8-my, sx, sy);
3987 }
3988
3989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if(quakeclk>0)
3990 rectfill(screen, // I don't know if these are right...
3991 scrx+32 - mx, //x1
3992 scry+8 - my + sy, //y1
3993 scrx+32 - mx + sx, //x2
3994 scry+8 - my + sy + (16 * scale_mul), //y2
3995 BLACK);
3996
3997 //stretch_blit(nosubscr?panorama:wavybuf,screen,0,0,256,224,scrx+32-128,scry+8-112,512,448);
3998 //if(quakeclk>0) rectfill(screen,scrx+32-128,scry+8-112+448,scrx+32-128+512,scry+8-112+456,0);
3999 3132 }
4000 else
4001 {
4002 blit(source,screen,0,0,scrx+32,scry+8,256,224);
4003
4004 if(quakeclk>0) rectfill(screen,scrx+32,scry+8+224,scrx+32+256,scry+8+232,BLACK);
4005 }
4006
4007
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(ShowFPS)// &&(frame&1))
4008 show_fps(screen);
4009
4010 3132 show_replay_controls(screen);
4011
4012
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(Paused)
4013 show_paused(screen);
4014
4015
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(details)
4016 {
4017 textprintf_ex(screen,font,0,SCREEN_H-8,254,BLACK,"%-6d (%s)", idle_count, time_str_long(idle_count));
4018 }
4019
4020 //if(panorama!=NULL) destroy_bitmap(panorama);
4021
4022 3132 ++framecnt;
4023
4024 3132 update_hw_screen();
4025 3132 }
4026
4027 //----------------------------------------------------------------
4028
4029 PALETTE sys_pal;
4030
4031 int32_t onGUISnapshot()
4032 {
4033 char buf[200];
4034 int32_t num=0;
4035 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
4036 do
4037 {
4038 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4039 }
4040 while(num<99999 && exists(buf));
4041
4042 BITMAP *b = create_bitmap_ex(8,resx,resy);
4043
4044 if(b)
4045 {
4046 if(MenuOpen)
4047 {
4048 //Cannot load game's palette while GUI elements are in focus. -Z
4049 //If there is a way to do this, then I have missed it.
4050 /*
4051 game_pal();
4052 RAMpal[253] = _RGB(0,0,0);
4053 RAMpal[254] = _RGB(63,63,63);
4054 set_palette_range(RAMpal,0,255,false);
4055 memcpy(RAMpal, snappal, sizeof(snappal));
4056 create_rgb_table(&rgb_table, RAMpal, NULL);
4057 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
4058 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
4059
4060 for(int32_t q=0; q<PAL_SIZE; q++)
4061 {
4062 trans_table2.data[0][q] = q;
4063 trans_table2.data[q][q] = q;
4064 }
4065 */
4066 //ringcolor(false);
4067 //get_palette(RAMpal);
4068 blit(screen,b,0,0,0,0,resx,resy);
4069 //al_trace("Menu Open\n");
4070 //game_pal();
4071 //PALETTE temppal;
4072 //get_palette(temppal);
4073 //system_pal();
4074 save_bitmap(buf,b,sys_pal);
4075 //save_bitmap(buf,b,RAMpal);
4076 //save_bitmap(buf,b,snappal);
4077 }
4078 else
4079 {
4080 blit(screen,b,0,0,0,0,resx,resy);
4081 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
4082 }
4083 destroy_bitmap(b);
4084 }
4085
4086 return D_O_K;
4087 }
4088
4089 int32_t onNonGUISnapshot()
4090 {
4091 PALETTE temppal;
4092 get_palette(temppal);
4093 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
4094
4095 char buf[200];
4096 int32_t num=0;
4097
4098 do
4099 {
4100 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4101 }
4102 while(num<99999 && exists(buf));
4103
4104 BITMAP *panorama = create_bitmap_ex(8,256,168);
4105 /*
4106 PALETTE tempRAMpal;
4107 get_palette(tempRAMpal);
4108
4109 if(tmpscr->flags3&fNOSUBSCR)
4110 {
4111 clear_to_color(panorama,0);
4112 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
4113 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
4114 }
4115 else
4116 {
4117 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
4118 }
4119
4120 destroy_bitmap(panorama);
4121 return D_O_K;
4122 */
4123 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
4124 {
4125 clear_to_color(panorama,0);
4126 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
4127 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
4128 }
4129 else
4130 {
4131 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
4132 }
4133
4134 destroy_bitmap(panorama);
4135 return D_O_K;
4136 }
4137
4138 int32_t onSnapshot()
4139 {
4140 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4141 {
4142 onGUISnapshot();
4143 }
4144 else
4145 {
4146 onNonGUISnapshot();
4147 }
4148
4149 return D_O_K;
4150 }
4151
4152 int32_t onSaveMapPic()
4153 {
4154 int32_t mapres2 = 0;
4155 char buf[200];
4156 int32_t num=0;
4157 mapscr tmpscr_b[2];
4158 mapscr tmpscr_c[6];
4159 BITMAP* _screen_draw_buffer = NULL;
4160 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4161 set_clip_state(_screen_draw_buffer,1);
4162
4163 for(int32_t i=0; i<6; ++i)
4164 {
4165 tmpscr_c[i] = tmpscr2[i];
4166 tmpscr2[i].zero_memory();
4167
4168 if(i>=2)
4169 {
4170 continue;
4171 }
4172
4173 tmpscr_b[i] = tmpscr[i];
4174 tmpscr[i].zero_memory();
4175 }
4176
4177 do
4178 {
4179 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4180 }
4181 while(num<99999 && exists(buf));
4182
4183 BITMAP* mappic = NULL;
4184
4185
4186 bool done=false, redraw=true;
4187
4188 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4189
4190 if(!mappic)
4191 {
4192 system_pal();
4193 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4194 game_pal();
4195 return D_O_K;;
4196 }
4197
4198 // draw the map
4199 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4200
4201 for(int32_t y=0; y<8; y++)
4202 {
4203 for(int32_t x=0; x<16; x++)
4204 {
4205 if(!displayOnMap(x, y))
4206 {
4207 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4208 }
4209 else
4210 {
4211 int32_t s = (y<<4) + x;
4212 loadscr2(1,s,-1);
4213
4214 for(int32_t i=0; i<6; i++)
4215 {
4216 if(tmpscr[1].layermap[i]<=0)
4217 continue;
4218
4219 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4220 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4221 {
4222 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4223
4224 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4225 }
4226 }
4227
4228 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4229
4230 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4231
4232 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4233 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4234
4235 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4236
4237 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4238 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4239 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4240 {
4241 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4242 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4243 }
4244 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4245
4246 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4247
4248 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4249 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4250 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4251 {
4252 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4253 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4254 }
4255 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4256 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4257
4258 }
4259
4260 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4261 }
4262 }
4263
4264 for(int32_t i=0; i<6; ++i)
4265 {
4266 tmpscr2[i]=tmpscr_c[i];
4267
4268 if(i>=2)
4269 {
4270 continue;
4271 }
4272
4273 tmpscr[i]=tmpscr_b[i];
4274 }
4275
4276 save_bitmap(buf,mappic,RAMpal);
4277 destroy_bitmap(mappic);
4278 destroy_bitmap(_screen_draw_buffer);
4279 return D_O_K;
4280 }
4281
4282 /*
4283 int32_t onSaveMapPic()
4284 {
4285 BITMAP* mappic = NULL;
4286 BITMAP* _screen_draw_buffer = NULL;
4287 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4288 int32_t mapres2 = 0;
4289 char buf[20];
4290 int32_t num=0;
4291 set_clip_state(_screen_draw_buffer,1);
4292 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4293
4294 do
4295 {
4296 sprintf(buf, "zelda%03d.png", ++num);
4297 }
4298 while(num<999 && exists(buf));
4299
4300 // if(!mappic) {
4301 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4302
4303 if(!mappic)
4304 {
4305 system_pal();
4306 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4307 game_pal();
4308 return D_O_K;
4309 }
4310
4311 // }
4312
4313 int32_t layermap, layerscreen;
4314 int32_t x2=0;
4315
4316 // draw the map
4317 for(int32_t y=0; y<8; y++)
4318 {
4319 for(int32_t x=0; x<16; x++)
4320 {
4321 int32_t s = (y<<4) + x;
4322
4323 if(!displayOnMap(x, y))
4324 {
4325 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4326 }
4327 else
4328 {
4329 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4330 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4331
4332 for(int32_t k=0; k<4; k++)
4333 {
4334 if(k==2)
4335 {
4336 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4337 }
4338
4339 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4340
4341 if(layermap>-1)
4342 {
4343 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4344
4345 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4346 {
4347 for(int32_t i=0; i<176; i++)
4348 {
4349 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4350 }
4351 }
4352 else
4353 {
4354 for(int32_t i=0; i<176; i++)
4355 {
4356 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4357 }
4358 }
4359 }
4360 }
4361
4362 for(int32_t i=0; i<176; i++)
4363 {
4364 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4365 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4366 {
4367 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4368 }
4369 }
4370
4371 for(int32_t k=4; k<6; k++)
4372 {
4373 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4374
4375 if(layermap>-1)
4376 {
4377 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4378
4379 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4380 {
4381 for(int32_t i=0; i<176; i++)
4382 {
4383 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4384 }
4385 }
4386 else
4387 {
4388 for(int32_t i=0; i<176; i++)
4389 {
4390 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4391 }
4392 }
4393 }
4394 }
4395 }
4396
4397 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4398 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4399 }
4400
4401 }
4402
4403 save_bitmap(buf,mappic,RAMpal);
4404 destroy_bitmap(mappic);
4405 destroy_bitmap(_screen_draw_buffer);
4406 return D_O_K;
4407 }
4408 */
4409
4410 void f_Quit(int32_t type)
4411 {
4412 if(type==qQUIT && !Playing)
4413 return;
4414
4415 music_pause();
4416 pause_all_sfx();
4417 system_pal();
4418 clear_keybuf();
4419
4420 replay_poll();
4421 if (replay_is_replaying())
4422 replay_peek_quit();
4423
4424 if (!replay_is_replaying())
4425 switch(type)
4426 {
4427 case qQUIT:
4428 onQuit();
4429 break;
4430
4431 case qRESET:
4432 onReset();
4433 break;
4434
4435 case qEXIT:
4436 onExit();
4437 break;
4438 }
4439
4440 if(Quit)
4441 {
4442 kill_sfx();
4443 music_stop();
4444 game_pal();
4445 clear_to_color(screen,BLACK);
4446 update_hw_screen();
4447 }
4448 else
4449 {
4450 game_pal();
4451 music_resume();
4452 resume_all_sfx();
4453 }
4454
4455 show_mouse(NULL);
4456 eat_buttons();
4457
4458 zc_readrawkey(KEY_ESC);
4459
4460 zc_readrawkey(KEY_ENTER);
4461 }
4462
4463 //----------------------------------------------------------------
4464
4465 int32_t onNoWalls()
4466 {
4467 cheats_enqueue(Cheat::Walls);
4468 return D_O_K;
4469 }
4470
4471 int32_t onIgnoreSideview()
4472 {
4473 cheats_enqueue(Cheat::IgnoreSideView);
4474 return D_O_K;
4475 }
4476
4477 3512 int32_t input_idle(bool checkmouse)
4478 {
4479 static int32_t mx, my, mz, mb;
4480
4481
4/6
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✓ Branch 3 taken 1966 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1546 times.
5058 if(keypressed() || zc_key_pressed() ||
4482
4/8
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1546 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1546 times.
✗ Branch 7 not taken.
1546 (checkmouse && (mx != gui_mouse_x() || my != gui_mouse_y() || mz != gui_mouse_z() || mb != gui_mouse_b())))
4483 {
4484 1966 idle_count = 0;
4485
4486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1966 times.
1966 if(active_count < MAX_ACTIVE)
4487 {
4488 1966 ++active_count;
4489 1966 }
4490 1966 }
4491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 else if(idle_count < MAX_IDLE)
4492 {
4493 1546 ++idle_count;
4494 1546 active_count = 0;
4495 1546 }
4496
4497 3512 mx = gui_mouse_x();
4498 3512 my = gui_mouse_y();
4499 3512 mz = gui_mouse_z();
4500 3512 mb = gui_mouse_b();
4501
4502 3512 return idle_count;
4503 }
4504
4505 int32_t onGoFast()
4506 {
4507 cheats_enqueue(Cheat::Fast);
4508 return D_O_K;
4509 }
4510
4511 int32_t onKillCheat()
4512 {
4513 cheats_enqueue(Cheat::Kill);
4514 return D_O_K;
4515 }
4516
4517 int32_t onShowLayer0()
4518 {
4519 show_layer_0 = !show_layer_0;
4520 return D_O_K;
4521 }
4522 int32_t onShowLayer1()
4523 {
4524 show_layer_1 = !show_layer_1;
4525 return D_O_K;
4526 }
4527 int32_t onShowLayer2()
4528 {
4529 show_layer_2 = !show_layer_2;
4530 return D_O_K;
4531 }
4532 int32_t onShowLayer3()
4533 {
4534 show_layer_3 = !show_layer_3;
4535 return D_O_K;
4536 }
4537 int32_t onShowLayer4()
4538 {
4539 show_layer_4 = !show_layer_4;
4540 return D_O_K;
4541 }
4542 int32_t onShowLayer5()
4543 {
4544 show_layer_5 = !show_layer_5;
4545 return D_O_K;
4546 }
4547 int32_t onShowLayer6()
4548 {
4549 show_layer_6 = !show_layer_6;
4550 return D_O_K;
4551 }
4552 int32_t onShowLayerO()
4553 {
4554 show_layer_over=!show_layer_over;
4555 return D_O_K;
4556 }
4557 int32_t onShowLayerP()
4558 {
4559 show_layer_push=!show_layer_push;
4560 return D_O_K;
4561 }
4562 int32_t onShowLayerS()
4563 {
4564 show_sprites=!show_sprites;
4565 return D_O_K;
4566 }
4567 int32_t onShowLayerF()
4568 {
4569 show_ffcs=!show_ffcs;
4570 return D_O_K;
4571 }
4572 int32_t onShowLayerW()
4573 {
4574 show_walkflags=!show_walkflags;
4575 return D_O_K;
4576 }
4577 int32_t onShowLayerE()
4578 {
4579 show_effectflags=!show_effectflags;
4580 return D_O_K;
4581 }
4582 int32_t onShowFFScripts()
4583 {
4584 show_ff_scripts=!show_ff_scripts;
4585 return D_O_K;
4586 }
4587 int32_t onShowHitboxes()
4588 {
4589 show_hitboxes=!show_hitboxes;
4590 return D_O_K;
4591 }
4592
4593 int32_t onLightSwitch()
4594 {
4595 cheats_enqueue(Cheat::Light);
4596 return D_O_K;
4597 }
4598
4599 int32_t onGoTo();
4600 int32_t onGoToComplete();
4601
4602 3512 void syskeys()
4603 {
4604 3512 update_system_keys();
4605
4606 int32_t oldtitle_version;
4607
4608
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(close_button_quit)
4609 {
4610 close_button_quit=false;
4611 f_Quit(qEXIT);
4612 }
4613
4614 3512 poll_joystick();
4615
4616
2/10
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3512 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3512 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4617 {
4618 oldtitle_version=title_version;
4619 System();
4620 }
4621
4622 3512 mouse_down=gui_mouse_b();
4623
4624
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(zc_read_system_key(KEY_F1))
4625 {
4626 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4627 {
4628 halt=!halt;
4629 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4630 }
4631 else
4632 {
4633 Throttlefps=!Throttlefps;
4634 logic_counter=0;
4635 }
4636 }
4637
4638 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4639 /*
4640 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4641 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4642 */
4643
4644
1/4
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3512 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4645
4646
1/4
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3512 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4647
4648
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(zc_read_system_key(KEY_F2)) ShowFPS=!ShowFPS;
4649
4650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3512 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4651
4652
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3512 if(zc_read_system_key(KEY_F4) && Playing)
4653 {
4654 Paused=true;
4655 Advance=true;
4656 }
4657
4658
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(zc_read_system_key(KEY_F6)) onTryQuit();
4659
4660 #ifndef ALLEGRO_MACOSX
4661 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4662
4663 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4664 #else
4665
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4666
4667
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4668 #endif
4669
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3512 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4670
4671
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if (zc_read_system_key(KEY_F12))
4672 {
4673 onSnapshot();
4674 }
4675
4676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3512 if(debug_enabled && zc_read_system_key(KEY_TAB))
4677 set_debug(!get_debug());
4678
4679
2/4
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3512 times.
3512 if(get_debug() || cheat>=1)
4680 {
4681 if( CheatModifierKeys() )
4682 {
4683 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4684
4685 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4686
4687 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4688
4689 if(zc_readkey(KEY_B))
4690 {
4691 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4692 }
4693
4694 if(zc_readkey(KEY_A))
4695 {
4696 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4697 }
4698 }
4699 }
4700
4701
2/4
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3512 times.
3512 if(get_debug() || cheat>=2)
4702 {
4703 if( CheatModifierKeys() )
4704 {
4705 if(rI())
4706 {
4707 cheats_enqueue(Cheat::Clock);
4708 }
4709 }
4710 }
4711
4712
2/4
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3512 times.
3512 if(get_debug() || cheat>=4)
4713 {
4714 if( CheatModifierKeys() )
4715 {
4716 if(rF11())
4717 {
4718 cheats_enqueue(Cheat::Walls);
4719 }
4720
4721 if(rQ())
4722 {
4723 cheats_enqueue(Cheat::Fast);
4724 }
4725
4726 if(zc_readkey(KEY_F))
4727 {
4728 cheats_enqueue(Cheat::Freeze);
4729 }
4730
4731 if(zc_readkey(KEY_G)) onGoToComplete();
4732
4733 if(zc_readkey(KEY_0)) onShowLayer0();
4734
4735 if(zc_readkey(KEY_1)) onShowLayer1();
4736
4737 if(zc_readkey(KEY_2)) onShowLayer2();
4738
4739 if(zc_readkey(KEY_3)) onShowLayer3();
4740
4741 if(zc_readkey(KEY_4)) onShowLayer4();
4742
4743 if(zc_readkey(KEY_5)) onShowLayer5();
4744
4745 if(zc_readkey(KEY_6)) onShowLayer6();
4746
4747 //if(zc_readkey(KEY_7)) onShowLayerO();
4748 if(zc_readkey(KEY_7)) onShowLayerF();
4749
4750 if(zc_readkey(KEY_8)) onShowLayerS();
4751
4752 if(zc_readkey(KEY_W)) onShowLayerW();
4753
4754 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4755
4756 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4757
4758 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4759 if(zc_readkey(KEY_O)) onShowLayerO();
4760 if(zc_readkey(KEY_P)) onShowLayerP();
4761 if(zc_readkey(KEY_C)) onShowHitboxes();
4762 if(zc_readkey(KEY_F)) onShowFFScripts();
4763 }
4764 }
4765
4766
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(volkeys)
4767 {
4768 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4769
4770 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4771
4772 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4773
4774 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4775 }
4776
4777
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3512 if(!get_debug() || !SystemKeys || replay_is_replaying())
4778 3512 goto bottom;
4779
4780 if(zc_readkey(KEY_D))
4781 {
4782 details = !details;
4783 rectfill(screen,0,0,319,7,BLACK);
4784 rectfill(screen,0,8,31,239,BLACK);
4785 rectfill(screen,288,8,319,239,BLACK);
4786 rectfill(screen,32,232,287,239,BLACK);
4787 }
4788
4789 if(zc_readkey(KEY_P)) Paused=!Paused;
4790
4791 //if(zc_readkey(KEY_P)) centerHero();
4792 if(zc_readkey(KEY_A))
4793 {
4794 Paused=true;
4795 Advance=true;
4796 }
4797
4798 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4799 #ifndef ALLEGRO_MACOSX
4800 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4801
4802 if(zc_readkey(KEY_F7))
4803 {
4804 Matrix(ss_speed, ss_density, 0);
4805 game_pal();
4806 }
4807 #else
4808 // The reason these are different on Mac in the first place is that
4809 // the OS doesn't let us use F9 and F10...
4810 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4811
4812 if(zc_readkey(KEY_F9))
4813 {
4814 Matrix(ss_speed, ss_density, 0);
4815 game_pal();
4816 }
4817 #endif
4818 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4819 {
4820 //change containers
4821 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4822 {
4823 //magic containers
4824 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4825 {
4826 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4827 }
4828 else
4829 {
4830 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4831 }
4832 }
4833 else
4834 {
4835 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4836 {
4837 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4838 }
4839 else
4840 {
4841 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4842 }
4843 }
4844 }
4845
4846 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4847 {
4848 //change containers
4849 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4850 {
4851 //magic containers
4852 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4853 {
4854 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4855 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4856 //heart containers
4857 }
4858 else
4859 {
4860 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4861 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4862 }
4863 }
4864 else
4865 {
4866 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4867 {
4868 game->set_magic(zc_max(game->get_magic()-1,0));
4869 }
4870 else
4871 {
4872 game->set_life(zc_max(game->get_life()-1,0));
4873 }
4874 }
4875 }
4876
4877 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4878
4879 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4880
4881 verifyBothWeapons();
4882
4883 bottom:
4884
4885
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(input_idle(true) > after_time())
4886 {
4887 Matrix(ss_speed, ss_density, 0);
4888 game_pal();
4889 }
4890 //Saffith's method of separating system and game key bindings. Can't do this!!
4891 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4892
4893 //while(Playing && keypressed())
4894 //readkey();
4895 // What's the Playing check for?
4896 3512 clear_keybuf();
4897 3512 }
4898
4899 void checkQuitKeys()
4900 {
4901 #ifndef ALLEGRO_MACOSX
4902 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4903
4904 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4905 #else
4906 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4907
4908 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4909 #endif
4910 }
4911
4912 bool CheatModifierKeys()
4913 {
4914 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4915 // to trigger cheats.
4916 if (replay_is_replaying())
4917 return false;
4918
4919 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4920 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4921 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4922 {
4923 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4924 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4925 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4926 {
4927 return true;
4928 }
4929 }
4930 return false;
4931 }
4932
4933 //99:05:54, for some reason?
4934 #define OLDMAXTIME 21405240
4935 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4936 #define MAXTIME 1944000000
4937
4938 3132 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4939 {
4940
2/2
✓ Branch 0 taken 1481 times.
✓ Branch 1 taken 1651 times.
3132 if(zcmusic!=NULL)
4941 {
4942 1651 zcmusic_poll();
4943 1651 }
4944
4945
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3132 times.
3132 while(Paused && !Advance && !Quit)
4946 {
4947 // have to call this, otherwise we'll get an infinite loop
4948 syskeys();
4949 if(allowF6Script)
4950 {
4951 FFCore.runF6Engine();
4952 }
4953 if (replay_get_mode() != ReplayMode::Assert)
4954 updatescr(allowwavy);
4955 throttleFPS();
4956
4957 #ifdef _WIN32
4958
4959 if(use_dwm_flush)
4960 {
4961 do_DwmFlush();
4962 }
4963
4964 #endif
4965
4966 // to keep music playing
4967 if(zcmusic!=NULL)
4968 {
4969 zcmusic_poll();
4970 }
4971 }
4972
4973
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if(Quit)
4974 return;
4975
4976
3/4
✓ Branch 0 taken 2681 times.
✓ Branch 1 taken 451 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2681 times.
3132 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4977 2681 game->change_time(1);
4978
4979 3132 Advance=false;
4980
4981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if (replay_is_active())
4982 {
4983
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if (replay_get_version() >= 3)
4984 replay_poll();
4985
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if (replay_get_version() >= 6)
4986 replay_peek_input();
4987 3132 }
4988 3132 update_keys();
4989
4990 3132 ++frame;
4991
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if (replay_is_replaying())
4993 3132 replay_do_cheats();
4994 3132 syskeys();
4995
4996 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4997 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4998 // approach here means it doesn't matter which call adds the cheat.
4999 3132 cheats_execute_queued();
5000
5001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if (replay_is_replaying())
5002 3132 replay_peek_quit();
5003
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if (GameFlags & GAMEFLAG_TRYQUIT)
5004 replay_step_quit(0);
5005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if(allowF6Script)
5006 {
5007 3132 FFCore.runF6Engine();
5008 3132 }
5009
2/2
✓ Branch 0 taken 3128 times.
✓ Branch 1 taken 4 times.
3132 if (Quit)
5010 4 replay_step_quit(Quit);
5011 // Someday... maybe install a Turbo button here?
5012 3132 updatescr(allowwavy);
5013 3132 throttleFPS();
5014
5015 #ifdef _WIN32
5016
5017 if(use_dwm_flush)
5018 {
5019 do_DwmFlush();
5020 }
5021
5022 #endif
5023
5024 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
5025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132 times.
3132 if(sfxcleanup)
5026 3132 sfx_cleanup();
5027 3132 }
5028
5029 void zapout()
5030 {
5031 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
5032 blit(framebuf,scrollbuf,0,0,256,0,256,224);
5033
5034 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5035 script_drawing_commands.Clear();
5036
5037 // zap out
5038 for(int32_t i=1; i<=24; i++)
5039 {
5040 draw_fuzzy(i);
5041 syskeys();
5042 advanceframe(true);
5043
5044 if(Quit)
5045 {
5046 break;
5047 }
5048 }
5049 }
5050
5051 void zapin()
5052 {
5053 FFCore.warpScriptCheck();
5054 draw_screen(tmpscr);
5055 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
5056 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5057 blit(framebuf,scrollbuf,0,0,256,0,256,224);
5058
5059 // zap out
5060 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5061 for(int32_t i=24; i>=1; i--)
5062 {
5063 draw_fuzzy(i);
5064 syskeys();
5065 advanceframe(true);
5066
5067 if(Quit)
5068 {
5069 break;
5070 }
5071 }
5072 }
5073
5074
5075 void wavyout(bool showhero)
5076 {
5077 draw_screen(tmpscr, showhero);
5078 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5079
5080 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
5081 clear_to_color(wavebuf,0);
5082 blit(framebuf,wavebuf,0,0,16,0,256,224);
5083
5084 static PALETTE wavepal;
5085
5086 int32_t ofs;
5087 int32_t amplitude=8;
5088
5089 int32_t wavelength=4;
5090 double palpos=0, palstep=4, palstop=126;
5091
5092 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5093 for(int32_t i=0; i<168; i+=wavelength)
5094 {
5095 for(int32_t l=0; l<256; l++)
5096 {
5097 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5098 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5099 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5100 }
5101
5102 palpos+=palstep;
5103
5104 if(palpos>=0)
5105 {
5106 hw_palette = &wavepal;
5107 update_hw_pal = true;
5108 }
5109 else
5110 {
5111 hw_palette = &RAMpal;
5112 update_hw_pal = true;
5113 }
5114
5115 for(int32_t j=0; j+playing_field_offset<224; j++)
5116 {
5117 for(int32_t k=0; k<256; k++)
5118 {
5119 ofs=0;
5120
5121 if((j<i)&&(j&1))
5122 {
5123 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5124 }
5125
5126 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5127 }
5128 }
5129
5130 syskeys();
5131 advanceframe(true);
5132
5133 // animate_combos();
5134 if(Quit)
5135 break;
5136 }
5137
5138 destroy_bitmap(wavebuf);
5139 }
5140
5141 void wavyin()
5142 {
5143 draw_screen(tmpscr);
5144 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5145
5146 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
5147 clear_to_color(wavebuf,0);
5148 blit(framebuf,wavebuf,0,0,16,0,256,224);
5149
5150 static PALETTE wavepal;
5151
5152 //Breaks dark rooms.
5153 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
5154 /*
5155 loadfullpal();
5156 loadlvlpal(DMaps[currdmap].color);
5157 ringcolor(false);
5158 */
5159 refreshpal=false;
5160 int32_t ofs;
5161 int32_t amplitude=8;
5162 int32_t wavelength=4;
5163 double palpos=168, palstep=4, palstop=126;
5164
5165 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5166 for(int32_t i=0; i<168; i+=wavelength)
5167 {
5168 for(int32_t l=0; l<256; l++)
5169 {
5170 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5171 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5172 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5173 }
5174
5175 palpos-=palstep;
5176
5177 if(palpos>=0)
5178 {
5179 hw_palette = &wavepal;
5180 update_hw_pal = true;
5181 }
5182 else
5183 {
5184 hw_palette = &RAMpal;
5185 update_hw_pal = true;
5186 }
5187
5188 for(int32_t j=0; j+playing_field_offset<224; j++)
5189 {
5190 for(int32_t k=0; k<256; k++)
5191 {
5192 ofs=0;
5193
5194 if((j<(167-i))&&(j&1))
5195 {
5196 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5197 }
5198
5199 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5200 }
5201 }
5202
5203 syskeys();
5204 advanceframe(true);
5205 // animate_combos();
5206
5207 if(Quit)
5208 break;
5209 }
5210
5211 destroy_bitmap(wavebuf);
5212 }
5213
5214 2 void blackscr(int32_t fcnt,bool showsubscr)
5215 {
5216 2 reset_pal_cycling();
5217 2 script_drawing_commands.Clear();
5218
5219 2 FFCore.warpScriptCheck();
5220 2 bool showtime = game->should_show_time();
5221
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 60 times.
62 while(fcnt>0)
5222 {
5223 60 clear_bitmap(framebuf);
5224
5225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(showsubscr)
5226 {
5227 60 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5228
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
60 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5229 {
5230 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5231 }
5232 60 }
5233
5234 60 syskeys();
5235 60 advanceframe(true);
5236
5237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(Quit)
5238 break;
5239
5240 60 --fcnt;
5241 }
5242 2 }
5243
5244 4 void openscreen(int32_t shape)
5245 {
5246 4 reset_pal_cycling();
5247 4 black_opening_count=0;
5248
5249
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(COOLSCROLL || shape>-1)
5250 {
5251 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5252 return;
5253 }
5254 else
5255 {
5256 4 Hero.setDontDraw(true);
5257 4 show_subscreen_dmap_dots=false;
5258 4 show_subscreen_numbers=false;
5259 // show_subscreen_items=false;
5260 4 show_subscreen_life=false;
5261 }
5262
5263 4 int32_t x=128;
5264
5265 4 FFCore.warpScriptCheck();
5266
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 320 times.
324 for(int32_t i=0; i<80; i++)
5267 {
5268 320 draw_screen(tmpscr);
5269 //? draw_screen already draws the subscreen -DD
5270 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5271 320 x=128-(((i*128/80)/8)*8);
5272
5273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(x>0)
5274 {
5275 320 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5276 320 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5277 320 }
5278
5279 // x=((80-i)/2)*4;
5280 /*
5281 --x;
5282 switch(++c)
5283 {
5284 case 5: c=0;
5285 case 0:
5286 case 2:
5287 case 3: --x; break;
5288 }
5289 */
5290 320 syskeys();
5291 320 advanceframe(true);
5292
5293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(Quit)
5294 {
5295 break;
5296 }
5297 320 }
5298
5299 4 Hero.setDontDraw(false);
5300 4 show_subscreen_items=true;
5301 4 show_subscreen_dmap_dots=true;
5302 4 }
5303
5304 void closescreen(int32_t shape)
5305 {
5306 reset_pal_cycling();
5307 black_opening_count=0;
5308
5309 if(COOLSCROLL || shape>-1)
5310 {
5311 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5312 return;
5313 }
5314 else
5315 {
5316 Hero.setDontDraw(true);
5317 show_subscreen_dmap_dots=false;
5318 show_subscreen_numbers=false;
5319 // show_subscreen_items=false;
5320 show_subscreen_life=false;
5321 }
5322
5323 int32_t x=128;
5324
5325 FFCore.warpScriptCheck();
5326 for(int32_t i=79; i>=0; --i)
5327 {
5328 draw_screen(tmpscr);
5329 //? draw_screen already draws the subscreen -DD
5330 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5331 x=128-(((i*128/80)/8)*8);
5332
5333 if(x>0)
5334 {
5335 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5336 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5337 }
5338
5339 // x=((80-i)/2)*4;
5340 /*
5341 --x;
5342 switch(++c)
5343 {
5344 case 5: c=0;
5345 case 0:
5346 case 2:
5347 case 3: --x; break;
5348 }
5349 */
5350 syskeys();
5351 advanceframe(true);
5352
5353 if(Quit)
5354 {
5355 break;
5356 }
5357 }
5358
5359 Hero.setDontDraw(false);
5360 show_subscreen_items=true;
5361 show_subscreen_dmap_dots=true;
5362 }
5363
5364 int32_t TriforceCount()
5365 {
5366 int32_t c=0;
5367
5368 for(int32_t i=1; i<=8; i++)
5369 if(game->lvlitems[i]&liTRIFORCE)
5370 ++c;
5371
5372 return c;
5373 }
5374
5375 int32_t onCustomGame()
5376 {
5377 int32_t file = getsaveslot();
5378
5379 if(file < 0)
5380 return D_O_K;
5381
5382 bool ret = (custom_game(file)!=0);
5383 return ret ? D_CLOSE : D_O_K;
5384 }
5385
5386 int32_t onContinue()
5387 {
5388 return D_CLOSE;
5389 }
5390
5391 int32_t onEsc() // Unused?? -L
5392 {
5393 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5394 }
5395
5396 int32_t onVsync()
5397 {
5398 Throttlefps = !Throttlefps;
5399 save_game_configs();
5400 return D_O_K;
5401 }
5402
5403 int32_t onWinPosSave()
5404 {
5405 SaveWinPos = !SaveWinPos;
5406 return D_O_K;
5407 }
5408
5409 int32_t onClickToFreeze()
5410 {
5411 ClickToFreeze = !ClickToFreeze;
5412 save_game_configs();
5413 return D_O_K;
5414 }
5415
5416 int32_t OnSaveZCConfig()
5417 {
5418 if(jwin_alert3(
5419 "Save Configuration",
5420 "Are you sure that you wish to save your present configuration settings?",
5421 "This will overwrite your prior settings!",
5422 NULL,
5423 "&Yes",
5424 "&No",
5425 NULL,
5426 'y',
5427 'n',
5428 0,
5429 lfont) == 1)
5430 {
5431 save_game_configs();
5432 return D_O_K;
5433 }
5434 else return D_O_K;
5435 }
5436
5437 int32_t OnnClearQuestDir()
5438 {
5439 if(jwin_alert3(
5440 "Clear Current Directory Cache",
5441 "Are you sure that you wish to clear the current cached directory?",
5442 "This will default the current directory to the ROOT for this instance of ZC Player!",
5443 NULL,
5444 "&Yes",
5445 "&No",
5446 NULL,
5447 'y',
5448 'n',
5449 0,
5450 lfont) == 1)
5451 {
5452 set_config_string("zeldadx","win_qst_dir","");
5453 flush_config_file();
5454 strcpy(qstdir,get_config_string("zeldadx","win_qst_dir",""));
5455 //strcpy(filepath,get_config_string("zeldadx","win_qst_dir",""));
5456 save_game_configs();
5457 #ifdef __EMSCRIPTEN__
5458 em_sync_fs();
5459 #endif
5460 return D_O_K;
5461 }
5462 else return D_O_K;
5463 }
5464
5465
5466 int32_t onConsoleZASM()
5467 {
5468 if ( !zasm_debugger )
5469 {
5470 AlertDialog("WARNING: ZASM Debugger",
5471 "Enabling this will open the ZASM Debugger Console"
5472 "\nThis will likely grind ZC to a halt with lag."
5473 "\nTo make any use of this, it is suggested that you read"
5474 "\nthe documentation for 'void Breakpoint(char[] string);'"
5475 " in 'ZScript_Additions.txt'"
5476 "\nThis is not recommended for normal users,"
5477 " and is only intended for ZC developers,"
5478 "\nor quest developers coding directly in ZASM"
5479 "\nAre you sure that you wish to open the ZASM Debugger?",
5480 [&](bool ret,bool)
5481 {
5482 if(ret)
5483 {
5484 FFCore.ZASMPrint(true);
5485 zasm_debugger = 1;
5486 save_game_configs();
5487 }
5488 }).show();
5489 return D_O_K;
5490 }
5491 else
5492 {
5493 zasm_debugger = 0;
5494 save_game_configs();
5495 FFCore.ZASMPrint(false);
5496 return D_O_K;
5497 }
5498 }
5499
5500
5501 int32_t onConsoleZScript()
5502 {
5503 if ( !zscript_debugger )
5504 {
5505 AlertDialog("ZScript Debugger",
5506 "Enabling this will open the ZScript Debugger Console"
5507 "\nThis will display any messages logged by scripts,"
5508 " including script errors."
5509 "\nAre you sure that you wish to open the ZScript Debugger?",
5510 [&](bool ret,bool)
5511 {
5512 if(ret)
5513 {
5514 FFCore.ZScriptConsole(true);
5515 zscript_debugger = 1;
5516 save_game_configs();
5517 }
5518 }).show();
5519 return D_O_K;
5520 }
5521 else
5522 {
5523 zscript_debugger = 0;
5524 save_game_configs();
5525 FFCore.ZScriptConsole(false);
5526 return D_O_K;
5527 }
5528 }
5529
5530
5531 int32_t onFrameSkip()
5532 {
5533 FrameSkip = !FrameSkip;
5534 return D_O_K;
5535 }
5536
5537 int32_t onSaveDragResize()
5538 {
5539 SaveDragResize = !SaveDragResize;
5540 return D_O_K;
5541 }
5542
5543 int32_t onDragAspect()
5544 {
5545 DragAspect = !DragAspect;
5546 return D_O_K;
5547 }
5548
5549 int32_t onTransLayers()
5550 {
5551 TransLayers = !TransLayers;
5552 save_game_configs();
5553 return D_O_K;
5554 }
5555
5556 int32_t onNESquit()
5557 {
5558 NESquit = !NESquit;
5559 save_game_configs();
5560 return D_O_K;
5561 }
5562
5563 int32_t onVolKeys()
5564 {
5565 volkeys = !volkeys;
5566 save_game_configs();
5567 return D_O_K;
5568 }
5569
5570 int32_t onShowFPS()
5571 {
5572 ShowFPS = !ShowFPS;
5573 scare_mouse();
5574
5575 if(ShowFPS)
5576 show_fps(screen);
5577
5578 if(sbig)
5579 stretch_blit(fps_undo,screen,0,0,64,16,scrx+40-120,scry+216+96,128,32);
5580 else
5581 blit(fps_undo,screen,0,0,scrx+40,scry+216,64,16);
5582
5583 if(Paused)
5584 show_paused(screen);
5585
5586 unscare_mouse();
5587 save_game_configs();
5588 return D_O_K;
5589 }
5590
5591 414416 bool is_Fkey(int32_t k)
5592 {
5593
2/2
✓ Branch 0 taken 42144 times.
✓ Branch 1 taken 372272 times.
414416 switch(k)
5594 {
5595 case KEY_F1:
5596 case KEY_F2:
5597 case KEY_F3:
5598 case KEY_F4:
5599 case KEY_F5:
5600 case KEY_F6:
5601 case KEY_F7:
5602 case KEY_F8:
5603 case KEY_F9:
5604 case KEY_F10:
5605 case KEY_F11:
5606 case KEY_F12:
5607 42144 return true;
5608 }
5609
5610 372272 return false;
5611 414416 }
5612
5613 void kb_getkey(DIALOG *d)
5614 {
5615 d->flags|=D_SELECTED;
5616
5617 scare_mouse();
5618 jwin_button_proc(MSG_DRAW,d,0);
5619 jwin_draw_win(screen, (resx-160)/2, (resy-48)/2, 160, 48, FR_WIN);
5620 // text_mode(vc(11));
5621 textout_centre_ex(screen, font, "Press a key", resx/2, resy/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5622 textout_centre_ex(screen, font, "ESC to cancel", resx/2, resy/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5623 unscare_mouse();
5624
5625 update_hw_screen(true);
5626
5627 clear_keybuf();
5628 int32_t k = next_press_key();
5629 clear_keybuf();
5630
5631 //shnarf
5632 //47=f1
5633 //59=esc
5634 if(k>0 && k<123 && !((k>46)&&(k<60)))
5635 *((int32_t*)d->dp3) = k;
5636
5637
5638 d->flags&=~D_SELECTED;
5639 }
5640
5641
5642 //Used by all keyboard key settings dialogues.
5643 void kb_clearjoystick(DIALOG *d)
5644 {
5645 d->flags|=D_SELECTED;
5646
5647 scare_mouse();
5648 jwin_button_proc(MSG_DRAW,d,0);
5649 jwin_draw_win(screen, (resx-160)/2, (resy-48)/2, 168, 48, FR_WIN);
5650 // text_mode(vc(11));
5651 textout_centre_ex(screen, font, "Press any key to clear", resx/2, resy/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5652 textout_centre_ex(screen, font, "ESC to cancel", resx/2, resy/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5653 unscare_mouse();
5654
5655 update_hw_screen();
5656
5657 clear_keybuf();
5658 int32_t k = next_press_key();
5659 clear_keybuf();
5660
5661 //shnarf
5662 //47=f1
5663 //59=esc
5664 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5665 // *((int32_t*)d->dp3) = k;
5666 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5667
5668
5669 d->flags&=~D_SELECTED;
5670 }
5671
5672 //Clears key to 0.
5673 //Used by all keyboard key settings dialogues.
5674 void kb_clearkey(DIALOG *d)
5675 {
5676 d->flags|=D_SELECTED;
5677
5678 scare_mouse();
5679 jwin_button_proc(MSG_DRAW,d,0);
5680 jwin_draw_win(screen, (resx-160)/2, (resy-48)/2, 160, 48, FR_WIN);
5681 // text_mode(vc(11));
5682 textout_centre_ex(screen, font, "Press any key to clear", resx/2, resy/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5683 textout_centre_ex(screen, font, "ESC to cancel", resx/2, resy/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5684 unscare_mouse();
5685
5686 update_hw_screen();
5687
5688 clear_keybuf();
5689 int32_t k = next_press_key();
5690 clear_keybuf();
5691
5692 //shnarf
5693 //47=f1
5694 //59=esc
5695 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5696 // *((int32_t*)d->dp3) = k;
5697 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5698
5699
5700 d->flags&=~D_SELECTED;
5701 }
5702
5703
5704 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5705 {
5706 switch(msg)
5707 {
5708 case MSG_KEY:
5709 case MSG_CLICK:
5710
5711 kb_clearjoystick(d);
5712
5713 while(gui_mouse_b())
5714 {
5715 clear_keybuf();
5716 rest(1);
5717 }
5718
5719 return D_REDRAW;
5720 }
5721
5722 return jwin_button_proc(msg,d,c);
5723 }
5724
5725 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5726 {
5727 switch(msg)
5728 {
5729 case MSG_KEY:
5730 case MSG_CLICK:
5731
5732 kb_getkey(d);
5733
5734 while(gui_mouse_b()) {
5735 clear_keybuf();
5736 rest(1);
5737 }
5738
5739 return D_REDRAW;
5740 }
5741
5742 return jwin_button_proc(msg,d,c);
5743 }
5744
5745 //Only used in keyboard settings dialogues to clear keys.
5746 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5747 {
5748 switch(msg)
5749 {
5750 case MSG_KEY:
5751 case MSG_CLICK:
5752
5753 kb_clearkey(d);
5754
5755 while(gui_mouse_b()) {
5756 clear_keybuf();
5757 rest(1);
5758 }
5759
5760 return D_REDRAW;
5761 }
5762
5763 return jwin_button_proc(msg,d,c);
5764 }
5765
5766 void j_getbtn(DIALOG *d)
5767 {
5768 d->flags|=D_SELECTED;
5769 scare_mouse();
5770 jwin_button_proc(MSG_DRAW,d,0);
5771 jwin_draw_win(screen, (resx-160)/2, (resy-48)/2, 160, 48, FR_WIN);
5772 // text_mode(vc(11));
5773 int32_t y = resy/2 - 12;
5774 textout_centre_ex(screen, font, "Press a button", resx/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5775 textout_centre_ex(screen, font, "ESC to cancel", resx/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5776 textout_centre_ex(screen, font, "SPACE to disable", resx/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5777 unscare_mouse();
5778
5779 update_hw_screen();
5780
5781 int32_t b = next_press_btn();
5782
5783 if(b>=0)
5784 *((int32_t*)d->dp3) = b;
5785
5786 d->flags&=~D_SELECTED;
5787
5788 if(!player) //safety first...
5789 player = init_dialog(d,-1);
5790
5791 player->joy_on = TRUE;
5792 }
5793
5794 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5795 {
5796 switch(msg)
5797 {
5798 case MSG_KEY:
5799 case MSG_CLICK:
5800
5801 j_getbtn(d);
5802
5803 while(gui_mouse_b()) {
5804 rest(1);
5805 clear_keybuf();
5806 }
5807
5808 return D_REDRAW;
5809 }
5810
5811 return jwin_button_proc(msg,d,c);
5812 }
5813
5814 //shnarf
5815 const char *key_str[] =
5816 {
5817 "(none) ", "a ", "b ", "c ",
5818 "d ", "e ", "f ", "g ",
5819 "h ", "i ", "j ", "k ",
5820 "l ", "m ", "n ", "o ",
5821 "p ", "q ", "r ", "s ",
5822 "t ", "u ", "v ", "w ",
5823 "x ", "y ", "z ", "0 ",
5824 "1 ", "2 ", "3 ", "4 ",
5825 "5 ", "6 ", "7 ", "8 ",
5826 "9 ", "num 0 ", "num 1 ", "num 2 ",
5827 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5828 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5829 "f2 ", "f3 ", "f4 ", "f5 ",
5830 "f6 ", "f7 ", "f8 ", "f9 ",
5831 "f10 ", "f11 ", "f12 ", "esc ",
5832 "~ ", "- ", "= ", "backspace ",
5833 "tab ", "{ ", "} ", "enter ",
5834 ": ", "quote ", "\\ ", "\\ (2) ",
5835 ", ", ". ", "/ ", "space ",
5836 "insert ", "delete ", "home ", "end ",
5837 "page up ", "page down ", "left ", "right ",
5838 "up ", "down ", "num / ", "num * ",
5839 "num - ", "num + ", "num delete ", "num enter ",
5840 "print screen ", "pause ", "abnt c1 ", "yen ",
5841 "kana ", "convert ", "no convert ", "at ",
5842 "circumflex ", ": (2) ", "kanji ", "num = ",
5843 "back quote ", "; ", "command ", "unknown (0) ",
5844 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5845 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5846 "right shift ", "left control ", "right control", "alt ",
5847 "alt gr ", "left win ", "right win ", "menu ",
5848 "scroll lock ", "number lock ", "caps lock ", "MAX"
5849 };
5850
5851
5852 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5853 //extern int32_t zcmusic_bufsz;
5854
5855 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5856 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5857
5858 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5859 {
5860 //these are here to bypass compiler warnings about unused arguments
5861 c=c;
5862
5863 if(msg==MSG_DRAW)
5864 {
5865 switch(d->w)
5866 {
5867 case 0:
5868 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5869 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5870 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5871 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5872 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5873 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5874 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5875 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5876 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5877 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5878 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5879 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5880 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5881 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5882 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5883 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5884 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5885 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5886 break;
5887
5888 case 1:
5889 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5890 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5891 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5892 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5893 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5894 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5895 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5896 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5897 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5898 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5899 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5900 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5901 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5902 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5903 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5904 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5905 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5906 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5907 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5908 break;
5909
5910 case 2:
5911 sprintf(str_a,"%3d",midi_volume);
5912 sprintf(str_b,"%3d",digi_volume);
5913 sprintf(str_l,"%3d",emusic_volume);
5914 sprintf(str_m,"%3dKB",zcmusic_bufsz);
5915 sprintf(str_r,"%3d",sfx_volume);
5916 strcpy(str_s,pan_str[pan_style]);
5917 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5918 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5919 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5920 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5921 break;
5922 }
5923 }
5924
5925 return D_O_K;
5926 }
5927
5928 int32_t set_vol(void *dp3, int32_t d2)
5929 {
5930 switch(((int32_t*)dp3)[0])
5931 {
5932 case 0:
5933 midi_volume = zc_min(d2<<3,255);
5934 break;
5935
5936 case 1:
5937 digi_volume = zc_min(d2<<3,255);
5938 break;
5939
5940 case 2:
5941 emusic_volume = zc_min(d2<<3,255);
5942 break;
5943
5944 case 3:
5945 sfx_volume = zc_min(d2<<3,255);
5946 break;
5947 }
5948
5949 scare_mouse();
5950 // text_mode(vc(11));
5951 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5952 unscare_mouse();
5953 return D_O_K;
5954 }
5955
5956 int32_t set_pan(void *dp3, int32_t d2)
5957 {
5958 pan_style = vbound(d2,0,3);
5959 scare_mouse();
5960 // text_mode(vc(11));
5961 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5962 unscare_mouse();
5963 return D_O_K;
5964 }
5965
5966 int32_t set_buf(void *dp3, int32_t d2)
5967 {
5968 scare_mouse();
5969 // text_mode(vc(11));
5970 zcmusic_bufsz = d2 + 1;
5971 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5972 unscare_mouse();
5973 return D_O_K;
5974 }
5975
5976 static int32_t gamepad_btn_list[] =
5977 {
5978 6,
5979 7,8,9,10,11,12,13,14,15,16,17,
5980 18,19,20,21,22,23,24,25,26,27,28,
5981 29,30,31,32,33,34,35,36,37,38,39,
5982 -1
5983 };
5984
5985 static int32_t gamepad_dirs_list[] =
5986 {
5987 40,41,42,43,
5988 44,45,46,47,
5989 48,49,50,51,
5990 52,53,54,55,
5991 56,
5992 -1
5993 };
5994
5995 static TABPANEL gamepad_tabs[] =
5996 {
5997 // (text)
5998 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5999 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
6000 { NULL, 0, NULL, 0, NULL }
6001 };
6002
6003 static DIALOG gamepad_dlg[] =
6004 {
6005 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6006 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
6007 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
6008 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6009 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6010 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6011 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6012 // 6
6013 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6014 // 7
6015 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6016 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
6017 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6018 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
6019 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
6020 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
6021 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
6022 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
6023 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
6024 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
6025 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
6026 // 18
6027 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
6028 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
6029 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
6030 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
6031 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
6032 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
6033 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
6034 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
6035 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
6036 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
6037 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
6038 // 29
6039 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
6040 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
6041 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
6042 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
6043 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
6044 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
6045 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
6046 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
6047 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
6048 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
6049 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
6050 // 40
6051 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6052 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6053 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
6054 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
6055 // 44
6056 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
6057 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
6058 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
6059 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
6060 // 48
6061 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
6062 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
6063 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
6064 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
6065 // 52
6066 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
6067 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
6068 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
6069 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
6070 // 56
6071 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
6072 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6073 };
6074
6075 static int32_t keyboard_keys_list[] =
6076 {
6077 6,7,8,9,10,
6078 11,12,13,14,15,16,17,18,19,20,
6079 21,22,23,24,25,26,27,28,29,30,
6080 31,32,33,34,35,36,37,38,39,40,
6081 -1
6082 };
6083
6084 static int32_t keyboard_dirs_list[] =
6085 {
6086 41,42,43,44,
6087 45,46,47,48,
6088 49,50,51,52,
6089 53,54,55,56,
6090 -1
6091 };
6092
6093 static int32_t keyboard_mods_list[] =
6094 {
6095 57,58,59,60,
6096 61,62,63,64,
6097 65,66,67,68,
6098 69,70,71,72,
6099 -1
6100 };
6101
6102 static TABPANEL keyboard_control_tabs[] =
6103 {
6104 // (text)
6105 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
6106 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
6107 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
6108 { NULL, 0, NULL, 0, NULL }
6109 };
6110
6111 static DIALOG keyboard_control_dlg[] =
6112 {
6113 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6114 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
6115 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
6116 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6117 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6118 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6119 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6120 // Keys
6121 // 6
6122 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6123 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6124 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6125 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
6126 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
6127 // 11
6128 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6129 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
6130 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6131 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
6132 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
6133 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
6134 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
6135 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
6136 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
6137 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
6138 // 21
6139 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
6140 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
6141 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
6142 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
6143 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
6144 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
6145 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
6146 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
6147 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
6148 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
6149 // 31
6150 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
6151 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
6152 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
6153 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
6154 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
6155 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
6156 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
6157 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
6158 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
6159 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
6160 // Dirs
6161 // 41
6162 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6163 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6164 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
6165 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
6166 // 45
6167 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
6168 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
6169 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
6170 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
6171 // 49
6172 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
6173 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
6174 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
6175 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
6176 // 53
6177 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
6178 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
6179 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
6180 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
6181 // Mods
6182 // 57
6183 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6184 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6185 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
6186 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
6187 // 61
6188 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
6189 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
6190 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
6191 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
6192 // 65
6193 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
6194 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
6195 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
6196 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
6197 // 69
6198 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
6199 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
6200 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
6201 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
6202 // 73
6203 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6204 };
6205
6206 /*
6207 int32_t midi_dp[3] = {0,147,104};
6208 int32_t digi_dp[3] = {1,147,120};
6209 int32_t pan_dp[3] = {0,147,136};
6210 int32_t buf_dp[3] = {0,147,152};
6211 */
6212 int32_t midi_dp[3] = {0,0,0};
6213 int32_t digi_dp[3] = {1,0,0};
6214 int32_t emus_dp[3] = {2,0,0};
6215 int32_t buf_dp[3] = {0,0,0};
6216 int32_t sfx_dp[3] = {3,0,0};
6217 int32_t pan_dp[3] = {0,0,0};
6218
6219 static DIALOG sound_dlg[] =
6220 {
6221 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6222 11 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6223 11 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6224 11 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6225 11 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6226 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6227 11 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6228 11 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6229 11 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6230 11 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6231 11 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6232 // 10
6233 11 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6234 11 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6235 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6236 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6237 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6238 11 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6239 11 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6240 11 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6241 11 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6242 11 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6243 //20
6244 11 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6245 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6246 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6247 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6248 11 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6249 11 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6250 11 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6251 11 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6252 11 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6253 11 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6254 //30
6255 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6256 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6257 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6258 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6259 };
6260
6261 char zc_builddate[80];
6262 char zc_aboutstr[80];
6263
6264 static DIALOG about_dlg[] =
6265 {
6266 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6267 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6268 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6269 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6270 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6271 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6272 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6273 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6274 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6275 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6276 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6277 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6278 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6279 };
6280
6281
6282 static DIALOG quest_dlg[] =
6283 {
6284 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6285 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6286 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6287 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6288 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6289 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6290 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, QHeader.version, NULL, NULL },
6291 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6292 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6293 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6294 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6295 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6296 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6297 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6298 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6299 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6300 };
6301
6302 static DIALOG triforce_dlg[] =
6303 {
6304 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6305 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6306 // 1
6307 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6308 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6309 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6310 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6311 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6312 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6313 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6314 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6315 // 9
6316 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6317 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6318 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6319 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6320 };
6321
6322 /*static DIALOG equip_dlg[] =
6323 {
6324 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6325 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6326 // 1
6327 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6328 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6329 // 3
6330 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6331 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6332 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6333 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6334 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6335 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6336 // 9
6337 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6338 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6339 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6340 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6341 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6342 // 14
6343 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6344 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6345 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6346 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6347 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6348 // 19
6349 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6350 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6351 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6352 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6353 // 23
6354 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6355 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6356 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6357 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6358 // 27
6359 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6360 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6361 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6362 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6363 // 31
6364 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6365 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6366 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6367 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6368 // 35
6369 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6370 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6371 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6372 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6373 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6374 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6375 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6376 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6377 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6378 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6379 };
6380
6381 static DIALOG items_dlg[] =
6382 {
6383 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6384 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6385 //1
6386 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6387 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6388 // 3
6389 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6390 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6391 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6392 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6393 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6394 // 8
6395 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6396 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6397 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6398 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6399 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6400 // 13
6401 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6402 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6403 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6404 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6405 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6406 // 18
6407 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6408 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6409 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6410 // 21
6411 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6412 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6413 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6414 // 24
6415 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6416 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6417 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6418 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6419 // 28
6420 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6421 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6422 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6423 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6424 // 32
6425 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6426 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6427 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6428 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6429 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6430 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6431 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6432 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6433 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6434 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6435 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6436 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6437 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6438 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6439 //45
6440 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6441 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6442 };*/
6443
6444
6445
6446 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6447 {
6448 go();
6449 int32_t ret=0;
6450 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6451 comeback();
6452 return ret != 0;
6453 }
6454
6455
6456 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6457 {
6458 if(def!=modulepath)
6459 strcpy(modulepath,def);
6460
6461 if(!usefilename)
6462 {
6463 int32_t i=(int32_t)strlen(modulepath);
6464
6465 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6466 modulepath[i--]=0;
6467 }
6468
6469 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6470 int32_t ret=0;
6471 int32_t sel=0;
6472
6473 if(list==NULL)
6474 {
6475 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6476 }
6477 else
6478 {
6479 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6480 }
6481
6482 return ret!=0;
6483 }
6484
6485 //The Dialogue that loads a ZMOD Module File
6486 int32_t zc_load_zmod_module_file()
6487 {
6488 if ( Playing )
6489 {
6490 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6491 return -1;
6492 }
6493 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6494 return D_CLOSE;
6495
6496 FILE *tempmodule = fopen(modulepath,"r");
6497
6498 if(tempmodule == NULL)
6499 {
6500 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6501 return -1;
6502 }
6503
6504
6505 //Set the module path:
6506 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6507 strcpy(moduledata.module_name, modulepath);
6508 al_trace("New Module Path is: %s \n", moduledata.module_name);
6509 set_config_string("ZCMODULE","current_module",moduledata.module_name);
6510 //save_game_configs();
6511 zcm.init(true); //Load the module values.
6512 moduledata.refresh_title_screen = 1;
6513 // refresh_select_screen = 1;
6514 build_biic_list();
6515 return D_O_K;
6516 }
6517
6518 static DIALOG module_info_dlg[] =
6519 {
6520 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6521
6522
6523 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6524 //1
6525 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6526 //2
6527 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6528 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6529 //4
6530 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6531 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6532 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6533 //7
6534
6535 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6536 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6537 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6538 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6539 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6540 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6541 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6542 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6543 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6544
6545 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6546 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6547 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6548 };
6549
6550 void about_zcplayer_module(const char *prompt,int32_t initialval)
6551 {
6552
6553 module_info_dlg[0].dp2 = lfont;
6554 if ( moduledata.moduletitle[0] != 0 )
6555 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6556
6557 if ( moduledata.moduleauthor[0] != 0 )
6558 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6559
6560 if ( moduledata.moduleinfo0[0] != 0 )
6561 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6562 if ( moduledata.moduleinfo1[0] != 0 )
6563 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6564 if ( moduledata.moduleinfo2[0] != 0 )
6565 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6566 if ( moduledata.moduleinfo3[0] != 0 )
6567 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6568 if ( moduledata.moduleinfo4[0] != 0 )
6569 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6570
6571 char module_date[255];
6572 memset(module_date, 0, sizeof(module_date));
6573 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6574 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6575
6576
6577
6578 char module_vers[255];
6579 memset(module_vers, 0, sizeof(module_vers));
6580 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6581
6582
6583 //sprintf(tilecount,"%d",1);
6584
6585 char module_build[255];
6586 memset(module_build, 0, sizeof(module_build));
6587 if ( moduledata.modbeta )
6588 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6589 else
6590 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6591
6592 module_info_dlg[12].dp = (char*)module_date;
6593 module_info_dlg[13].dp = (char*)module_vers;
6594 module_info_dlg[14].dp = (char*)module_build;
6595
6596 if(is_large)
6597 large_dialog(module_info_dlg);
6598
6599 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6600 jwin_center_dialog(module_info_dlg);
6601
6602
6603 }
6604
6605 int32_t onAbout_ZCP_Module()
6606 {
6607 about_zcplayer_module("About Module (.zmod)", 0);
6608 return D_O_K;
6609 }
6610
6611 //New Modules Menu for 2.55+
6612 static MENU zcmodule_menu[] =
6613 {
6614 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6615 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6616
6617 { NULL, NULL, NULL, 0, NULL }
6618 };
6619
6620 int32_t onToggleRecordingNewSaves()
6621 {
6622 if (zc_get_config("zeldadx", "replay_new_saves", false))
6623 {
6624 zc_set_config("zeldadx", "replay_new_saves", false);
6625 }
6626 else
6627 {
6628 zc_set_config("zeldadx", "replay_new_saves", true);
6629 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6630 NULL,NULL,"OK",NULL,13,27,lfont);
6631 }
6632 return D_O_K;
6633 }
6634
6635 int32_t onStopReplayOrRecord()
6636 {
6637 if (replay_is_replaying())
6638 {
6639 replay_quit();
6640 }
6641 else if (replay_get_mode() == ReplayMode::Record)
6642 {
6643 if (!replay_get_meta_bool("test_mode"))
6644 {
6645 jwin_alert("Recording", "You cannot stop recording a save file.",
6646 NULL,NULL,"OK",NULL,13,27,lfont);
6647 return D_CLOSE;
6648 }
6649
6650 if (jwin_alert("Stop Recording",
6651 "Save replay to disk and stop recording?",
6652 "This will stop the recording.",
6653 NULL,
6654 "Yes","No",13,27,lfont) != 1)
6655 return D_CLOSE;
6656
6657 replay_save();
6658 replay_stop();
6659 }
6660 return D_O_K;
6661 }
6662
6663 static int32_t handle_on_load_replay(ReplayMode mode)
6664 {
6665 if (Playing)
6666 {
6667 if (jwin_alert("Replay - Warning!",
6668 "Loading a replay will exit the current game.",
6669 "All unsaved progress will be lost.",
6670 "Do you wish to continue?",
6671 "Yes","No",13,27,lfont) != 1)
6672 return D_CLOSE;
6673 }
6674
6675 std::string mode_string = replay_mode_to_string(mode);
6676 mode_string[0] = std::toupper(mode_string[0]);
6677
6678 std::string line_1 = "Select a replay file to play back.";
6679 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6680 std::string line_3 = "You can stop the replay and take over manually any time.";
6681 if (mode == ReplayMode::Update)
6682 {
6683 line_1 = "Select a replay file to update.";
6684 line_2 = "WARNING: be sure to back up the zplay file";
6685 line_3 = "and verify that the updated replay works as expected!";
6686 }
6687
6688 if (jwin_alert(mode_string.c_str(),
6689 line_1.c_str(),
6690 line_2.c_str(),
6691 line_3.c_str(),
6692 "OK","Nevermind",13,27,lfont) == 1)
6693 {
6694 char replay_path[2048];
6695 strcpy(replay_path, "replays/");
6696 if (jwin_file_select_ex(
6697 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6698 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6699 return D_CLOSE;
6700
6701 replay_quit();
6702 load_replay_file_deferred(mode, replay_path);
6703 Quit = qRESET;
6704 return D_CLOSE;
6705 }
6706 return D_O_K;
6707 }
6708
6709 int32_t onLoadReplay()
6710 {
6711 return handle_on_load_replay(ReplayMode::Replay);
6712 }
6713
6714 int32_t onLoadReplayAssert()
6715 {
6716 return handle_on_load_replay(ReplayMode::Assert);
6717 }
6718
6719 int32_t onLoadReplayUpdate()
6720 {
6721 return handle_on_load_replay(ReplayMode::Update);
6722 }
6723
6724 int32_t onSaveReplay()
6725 {
6726 if (replay_get_mode() == ReplayMode::Record)
6727 {
6728 if (!replay_get_meta_bool("test_mode"))
6729 {
6730 if (jwin_alert("Save Replay",
6731 "This will save a copy of the replay up to this point.",
6732 "The official replay file will be untouched.",
6733 "Do you wish to continue?",
6734 "Yes","No",13,27,lfont) != 1)
6735 return D_CLOSE;
6736
6737 char replay_path[2048];
6738 strcpy(replay_path, replay_get_filename().c_str());
6739 if (jwin_file_select_ex(
6740 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6741 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6742 return D_CLOSE;
6743
6744 if (fileexists(replay_path))
6745 {
6746 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6747 NULL,NULL,"OK",NULL,13,27,lfont);
6748 return D_CLOSE;
6749 }
6750
6751 replay_save(replay_path);
6752 }
6753 else
6754 {
6755 replay_save();
6756 }
6757 }
6758 return D_O_K;
6759 }
6760
6761 static MENU replay_menu[] =
6762 {
6763 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6764 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6765 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6766 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6767 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6768 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6769
6770 { NULL, NULL, NULL, 0, NULL }
6771 };
6772
6773 static DIALOG credits_dlg[] =
6774 {
6775 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6776 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6777 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6778 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6779 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6780 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6781 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6782 };
6783
6784 11 static ListData dmap_list(dmaplist, &font);
6785
6786 static DIALOG goto_dlg[] =
6787 {
6788 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6789 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6790 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6791 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6792 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6793 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6794 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6795 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6796 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6797 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6798 };
6799
6800 int32_t onGoTo()
6801 {
6802 bool music = false;
6803 music = music;
6804 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6805
6806 goto_dlg[0].dp2=lfont;
6807 goto_dlg[4].d2=cheat_goto_dmap;
6808 goto_dlg[6].dp=cheat_goto_screen_str;
6809
6810 clear_keybuf();
6811
6812 if(is_large)
6813 large_dialog(goto_dlg);
6814
6815 if(zc_popup_dialog(goto_dlg,4)==1)
6816 {
6817 // dmap, screen
6818 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6819 };
6820
6821 return D_O_K;
6822 }
6823
6824 int32_t onGoToComplete()
6825 {
6826 if(!Playing)
6827 {
6828 return D_O_K;
6829 }
6830
6831 system_pal();
6832 music_pause();
6833 pause_all_sfx();
6834 show_mouse(screen);
6835 onGoTo();
6836 eat_buttons();
6837
6838 zc_readrawkey(KEY_ESC);
6839
6840 show_mouse(NULL);
6841 game_pal();
6842 music_resume();
6843 resume_all_sfx();
6844 return D_O_K;
6845 }
6846
6847 int32_t onCredits()
6848 {
6849 go();
6850
6851 BITMAP *win = create_bitmap_ex(8,222,110);
6852
6853 if(!win)
6854 return D_O_K;
6855
6856 int32_t c=0;
6857 int32_t l=0;
6858 int32_t ol=-1;
6859 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6860 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6861 PALETTE tmppal;
6862
6863 clear_bitmap(win);
6864 draw_rle_sprite(win,rle,0,0);
6865 credits_dlg[0].dp2=lfont;
6866 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6867 credits_dlg[2].dp = win;
6868 set_palette_range(black_palette,0,127,false);
6869
6870 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6871
6872 while(update_dialog(p))
6873 {
6874 throttleFPS();
6875 #ifdef __EMSCRIPTEN__
6876 all_render_screen();
6877 #endif
6878 ++c;
6879 l = zc_max((c>>1)-30,0);
6880
6881 if(l > rle->h)
6882 l = c = 0;
6883
6884 if(l > rle->h - 112)
6885 l = rle->h - 112;
6886
6887 clear_bitmap(win);
6888 draw_rle_sprite(win,rle,0,0-l);
6889
6890 if(c<=64)
6891 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6892
6893 set_palette_range(tmppal,0,127,false);
6894
6895 if(l!=ol)
6896 {
6897 scare_mouse();
6898 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6899 unscare_mouse();
6900 SCRFIX();
6901 ol=l;
6902 }
6903 }
6904
6905 shutdown_dialog(p);
6906 destroy_bitmap(win);
6907 comeback();
6908 return D_O_K;
6909 }
6910
6911 const char *midilist(int32_t index, int32_t *list_size)
6912 {
6913 if(index<0)
6914 {
6915 *list_size=0;
6916
6917 for(int32_t i=0; i<MAXMIDIS; i++)
6918 if(tunes[i].data)
6919 ++(*list_size);
6920
6921 return NULL;
6922 }
6923
6924 int32_t i=0,m=0;
6925
6926 while(m<=index && i<=MAXMIDIS)
6927 {
6928 if(tunes[i].data)
6929 ++m;
6930
6931 ++i;
6932 }
6933
6934 --i;
6935
6936 if(i==MAXMIDIS && m<index)
6937 return "(null)";
6938
6939 return tunes[i].title;
6940 }
6941
6942 /* ------- MIDI info stuff -------- */
6943
6944 char *text;
6945 midi_info *zmi;
6946 bool dialog_running;
6947 bool listening;
6948
6949 void get_info(int32_t index);
6950
6951 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6952 {
6953 int32_t d2 = d->d2;
6954 int32_t ret = jwin_droplist_proc(msg,d,c);
6955
6956 if(d2!=d->d2)
6957 {
6958 get_info(d->d2);
6959 }
6960
6961 return ret;
6962 }
6963
6964 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6965 {
6966 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6967
6968 int32_t ret = jwin_button_proc(msg,d,c);
6969
6970 if(ret == D_CLOSE)
6971 {
6972 // get current midi index
6973 int32_t index = (d+(d->d1))->d2;
6974 int32_t i=0, m=0;
6975
6976 while(m<=index && i<=MAXMIDIS)
6977 {
6978 if(tunes[i].data)
6979 ++m;
6980
6981 ++i;
6982 }
6983
6984 --i;
6985 jukebox(i);
6986 listening = true;
6987 ret = D_O_K;
6988 }
6989
6990 return ret;
6991 }
6992
6993 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6994 {
6995 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6996
6997 int32_t ret = jwin_button_proc(msg,d,c);
6998
6999 if(ret == D_CLOSE)
7000 {
7001 // get current midi index
7002 int32_t index = (d+(d->d1))->d2;
7003 int32_t i=0, m=0;
7004
7005 while(m<=index && i<=MAXMIDIS)
7006 {
7007 if(tunes[i].data)
7008 ++m;
7009
7010 ++i;
7011 }
7012
7013 --i;
7014
7015 // get file name
7016
7017 int32_t sel=0;
7018 //struct ffblk f;
7019 char title[40] = "Save MIDI: ";
7020 char fname[2048];
7021 memset(fname,0,2048);
7022 static EXT_LIST list[] =
7023 {
7024 { (char *)"MIDI files (*.mid)", (char *)"mid" },
7025 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
7026 { NULL, NULL }
7027 };
7028
7029 strcpy(title+11, tunes[i].title);
7030 title[39] = '\0';
7031
7032 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
7033 goto done;
7034
7035 if(exists(fname))
7036 {
7037 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
7038 goto done;
7039 }
7040
7041 // save midi i
7042
7043 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
7044 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
7045
7046 done:
7047 chop_path(fname);
7048 ret = D_REDRAW;
7049 }
7050
7051 return ret;
7052 }
7053
7054 11 static ListData midi_list(midilist, &font);
7055
7056 static DIALOG midi_dlg[] =
7057 {
7058 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7059 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
7060 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
7061 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
7062 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7063 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
7064 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
7065 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
7066 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7067 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7068 };
7069
7070 void get_info(int32_t index)
7071 {
7072 int32_t i=0, m=0;
7073
7074 while(m<=index && i<=MAXMIDIS)
7075 {
7076 if(tunes[i].data)
7077 ++m;
7078
7079 ++i;
7080 }
7081
7082 --i;
7083
7084 if(i==MAXMIDIS && m<index)
7085 strcpy(text,"(null)");
7086 else
7087 {
7088 get_midi_info((MIDI*)tunes[i].data,zmi);
7089 get_midi_text((MIDI*)tunes[i].data,zmi,text);
7090 }
7091
7092 midi_dlg[0].dp2=lfont;
7093 midi_dlg[3].dp = text;
7094 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
7095 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
7096
7097 if(dialog_running)
7098 {
7099 scare_mouse();
7100 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
7101 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
7102 unscare_mouse();
7103 }
7104 }
7105
7106 int32_t onMIDICredits()
7107 {
7108 text = (char*)malloc(4096);
7109 zmi = (midi_info*)malloc(sizeof(midi_info));
7110
7111 if(!text || !zmi)
7112 {
7113 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
7114 return D_O_K;
7115 }
7116
7117 bool do_pause_midi = midi_pos >= 0 && currmidi;
7118 auto restore_midi = currmidi;
7119 if(do_pause_midi)
7120 {
7121 paused_midi_pos = midi_pos;
7122 stop_midi();
7123 midi_paused=true;
7124 midi_suspended = midissuspHALTED;
7125 }
7126
7127 midi_dlg[0].dp2=lfont;
7128 midi_dlg[2].d1 = 0;
7129 midi_dlg[2].d2 = 0;
7130 midi_dlg[4].flags = D_EXIT;
7131 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
7132
7133 listening = false;
7134 dialog_running=false;
7135 get_info(0);
7136
7137 dialog_running=true;
7138
7139 if(is_large)
7140 large_dialog(midi_dlg);
7141
7142 zc_popup_dialog(midi_dlg,0);
7143 dialog_running=false;
7144
7145 if(listening)
7146 music_stop();
7147
7148 if(do_pause_midi)
7149 {
7150 midi_suspended = midissuspRESUME;
7151 currmidi = restore_midi;
7152 midi_pos = paused_midi_pos;
7153 }
7154
7155 if(text) free(text);
7156 if(zmi) free(zmi);
7157 return D_O_K;
7158 }
7159
7160 int32_t onAbout()
7161 {
7162 char buf1[80]={0};
7163 std::ostringstream oss;
7164 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
7165 oss << buf1 << '\n';
7166 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
7167 oss << buf1 << '\n';
7168 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
7169 oss << buf1 << '\n';
7170 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
7171 oss << buf1 << '\n';
7172
7173 InfoDialog("About ZC", oss.str()).show();
7174 return D_O_K;
7175 }
7176
7177 int32_t onQuest()
7178 {
7179 char fname[100];
7180 strcpy(fname, get_filename(qstpath));
7181 quest_dlg[0].dp2=lfont;
7182 quest_dlg[1].dp = fname;
7183
7184 if(QHeader.quest_number==0)
7185 sprintf(str_a,"Custom");
7186 else
7187 sprintf(str_a,"%d",QHeader.quest_number);
7188
7189 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
7190
7191 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
7192 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
7193
7194 if(is_large)
7195 large_dialog(quest_dlg);
7196
7197 zc_popup_dialog(quest_dlg, 0);
7198 return D_O_K;
7199 }
7200
7201 void call_vidmode_dlg();
7202 int32_t onVidMode()
7203 {
7204 call_vidmode_dlg();
7205 return D_O_K;
7206 }
7207
7208 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7209 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7210 //Added an extra statement, so that if the key is cleared to 0, the cleared
7211 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7212
7213 void load_ukeys(int32_t* arr)
7214 {
7215 arr[ukey_a] = Akey;
7216 arr[ukey_b] = Bkey;
7217 arr[ukey_s] = Skey;
7218 arr[ukey_l] = Lkey;
7219 arr[ukey_r] = Rkey;
7220 arr[ukey_p] = Pkey;
7221 arr[ukey_ex1] = Exkey1;
7222 arr[ukey_ex2] = Exkey2;
7223 arr[ukey_ex3] = Exkey3;
7224 arr[ukey_ex4] = Exkey4;
7225 arr[ukey_du] = DUkey;
7226 arr[ukey_dd] = DDkey;
7227 arr[ukey_dl] = DLkey;
7228 arr[ukey_dr] = DRkey;
7229 arr[ukey_mod1a] = cheat_modifier_keys[0];
7230 arr[ukey_mod1b] = cheat_modifier_keys[1];
7231 arr[ukey_mod2a] = cheat_modifier_keys[2];
7232 arr[ukey_mod2b] = cheat_modifier_keys[3];
7233 };
7234
7235 static const char* ukey_names[] = {
7236 "A", "B", "Start", "L", "R", "Map",
7237 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7238 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7239 "Cheat Mod R1", "Cheat Mod R2",
7240 };
7241 std::string get_ukey_name(int32_t k)
7242 {
7243 if (k < num_ukey) return ukey_names[k];
7244 return "";
7245 }
7246
7247 int32_t onKeyboard()
7248 {
7249 int32_t a = Akey;
7250 int32_t b = Bkey;
7251 int32_t s = Skey;
7252 int32_t l = Lkey;
7253 int32_t r = Rkey;
7254 int32_t p = Pkey;
7255 int32_t ex1 = Exkey1;
7256 int32_t ex2 = Exkey2;
7257 int32_t ex3 = Exkey3;
7258 int32_t ex4 = Exkey4;
7259 int32_t du = DUkey;
7260 int32_t dd = DDkey;
7261 int32_t dl = DLkey;
7262 int32_t dr = DRkey;
7263 int32_t mod1a = cheat_modifier_keys[0];
7264 int32_t mod1b = cheat_modifier_keys[1];
7265 int32_t mod2a = cheat_modifier_keys[2];
7266 int32_t mod2b = cheat_modifier_keys[3];
7267 bool done=false;
7268 int32_t ret;
7269
7270 keyboard_control_dlg[0].dp2=lfont;
7271
7272 if(is_large)
7273 large_dialog(keyboard_control_dlg);
7274
7275 while(!done)
7276 {
7277 ret = zc_popup_dialog(keyboard_control_dlg,3);
7278
7279 if(ret==3) // OK
7280 {
7281 int32_t ukeys[num_ukey];
7282 load_ukeys(ukeys);
7283 std::vector<std::string> uniqueError;
7284 for(int32_t q = 0; q < num_ukey; ++q)
7285 {
7286 for(int32_t p = q+1; p < num_ukey; ++p)
7287 {
7288 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7289 {
7290 char buf[64];
7291 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7292 std::string str(buf);
7293 uniqueError.push_back(str);
7294 }
7295 }
7296 }
7297 if(uniqueError.size() == 0)
7298 done = true;
7299 else
7300 {
7301 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7302 box_out("Cannot have duplicate keybinds!"); box_eol();
7303 for(std::vector<std::string>::iterator it = uniqueError.begin();
7304 it != uniqueError.end(); ++it)
7305 {
7306 box_out((*it).c_str()); box_eol();
7307 }
7308 box_end(true);
7309 }
7310 /* Old uniqueness check
7311 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7312 bool unique = true;
7313 addToHash(A,unique,keyhash);
7314 addToHash(B,unique,keyhash);
7315 addToHash(S,unique,keyhash);
7316 addToHash(L,unique,keyhash);
7317 addToHash(R,unique,keyhash);
7318 addToHash(P,unique,keyhash);
7319 addToHash(DU,unique,keyhash);
7320 addToHash(DD,unique,keyhash);
7321 addToHash(DL,unique,keyhash);
7322 addToHash(DR,unique,keyhash);
7323
7324 if(keyhash->find(Exkey1) == keyhash->end())
7325 {
7326 (*keyhash)[Exkey1]=true;
7327 }
7328 else
7329 {
7330 if ( Exkey1 != 0 ) unique = false;
7331 }
7332
7333 if(keyhash->find(Exkey2) == keyhash->end())
7334 {
7335 (*keyhash)[Exkey2]=true;
7336 }
7337 else
7338 {
7339 if ( Exkey2 != 0 ) unique = false;
7340 }
7341
7342 if(keyhash->find(Exkey3) == keyhash->end())
7343 {
7344 (*keyhash)[Exkey3]=true;
7345 }
7346 else
7347 {
7348 if ( Exkey3 != 0 ) unique = false;
7349 }
7350
7351 if(keyhash->find(Exkey4) == keyhash->end())
7352 {
7353 (*keyhash)[Exkey4]=true;
7354 }
7355 else
7356 {
7357 if ( Exkey4 != 0 )unique = false;
7358 }
7359 //modifier keys
7360 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7361 {
7362 (*keyhash)[cheat_modifier_keys[0]]=true;
7363 }
7364 else
7365 {
7366 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7367 }
7368 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7369 {
7370 (*keyhash)[cheat_modifier_keys[1]]=true;
7371 }
7372 else
7373 {
7374 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7375 }
7376 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7377 {
7378 (*keyhash)[cheat_modifier_keys[2]]=true;
7379 }
7380 else
7381 {
7382 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7383 }
7384 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7385 {
7386 (*keyhash)[cheat_modifier_keys[3]]=true;
7387 }
7388 else
7389 {
7390 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7391 }
7392
7393 delete keyhash;
7394
7395 if(unique)
7396 done=true;
7397 else
7398 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7399 */
7400 }
7401 else // Cancel
7402 {
7403 Akey = a;
7404 Bkey = b;
7405 Skey = s;
7406 Lkey = l;
7407 Rkey = r;
7408 Pkey = p;
7409 Exkey1 = ex1;
7410 Exkey2 = ex2;
7411 Exkey3 = ex3;
7412 Exkey4 = ex4;
7413 DUkey = du;
7414 DDkey = dd;
7415 DLkey = dl;
7416 DRkey = dr;
7417 cheat_modifier_keys[0] = mod1a;
7418 cheat_modifier_keys[1] = mod1b;
7419 cheat_modifier_keys[2] = mod2a;
7420 cheat_modifier_keys[3] = mod2b;
7421
7422 done=true;
7423 }
7424
7425 rest(1);
7426 }
7427
7428 save_game_configs();
7429 return D_O_K;
7430 }
7431
7432 int32_t onGamepad()
7433 {
7434 int32_t a = Abtn;
7435 int32_t b = Bbtn;
7436 int32_t s = Sbtn;
7437 int32_t l = Lbtn;
7438 int32_t r = Rbtn;
7439 int32_t m = Mbtn;
7440 int32_t p = Pbtn;
7441 int32_t ex1 = Exbtn1;
7442 int32_t ex2 = Exbtn2;
7443 int32_t ex3 = Exbtn3;
7444 int32_t ex4 = Exbtn4;
7445 int32_t up = DUbtn;
7446 int32_t down = DDbtn;
7447 int32_t left = DLbtn;
7448 int32_t right = DRbtn;
7449
7450 gamepad_dlg[0].dp2=lfont;
7451 if(analog_movement)
7452 gamepad_dlg[56].flags|=D_SELECTED;
7453 else
7454 gamepad_dlg[56].flags&=~D_SELECTED;
7455
7456 if(is_large)
7457 large_dialog(gamepad_dlg);
7458
7459 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7460
7461 if(ret == 4) //OK
7462 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7463 else //Cancel
7464 {
7465 Abtn = a;
7466 Bbtn = b;
7467 Sbtn = s;
7468 Lbtn = l;
7469 Rbtn = r;
7470 Mbtn = m;
7471 Pbtn = p;
7472 Exbtn1 = ex1;
7473 Exbtn2 = ex2;
7474 Exbtn3 = ex3;
7475 Exbtn4 = ex4;
7476 DUbtn = up;
7477 DDbtn = down;
7478 DLbtn = left;
7479 DRbtn = right;
7480 }
7481
7482 save_game_configs();
7483 return D_O_K;
7484 }
7485
7486 int32_t onSound()
7487 {
7488 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7489 {
7490 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7491 }
7492 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7493 {
7494 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7495 }
7496 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7497 {
7498 emusic_volume = (int32_t)FFCore.usr_music_volume;
7499 }
7500 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7501 {
7502 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7503 }
7504 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7505 {
7506 pan_style = (int32_t)FFCore.usr_panstyle;
7507 }
7508
7509 int32_t m = midi_volume;
7510 int32_t d = digi_volume;
7511 int32_t e = emusic_volume;
7512 int32_t b = zcmusic_bufsz;
7513 int32_t s = sfx_volume;
7514 int32_t p = pan_style;
7515 pan_style = vbound(pan_style,0,3);
7516
7517 sound_dlg[0].dp2=lfont;
7518
7519 if(is_large)
7520 large_dialog(sound_dlg);
7521
7522 midi_dp[1] = sound_dlg[6].x;
7523 midi_dp[2] = sound_dlg[6].y;
7524 digi_dp[1] = sound_dlg[7].x;
7525 digi_dp[2] = sound_dlg[7].y;
7526 emus_dp[1] = sound_dlg[8].x;
7527 emus_dp[2] = sound_dlg[8].y;
7528 buf_dp[1] = sound_dlg[9].x;
7529 buf_dp[2] = sound_dlg[9].y;
7530 sfx_dp[1] = sound_dlg[10].x;
7531 sfx_dp[2] = sound_dlg[10].y;
7532 pan_dp[1] = sound_dlg[11].x;
7533 pan_dp[2] = sound_dlg[11].y;
7534 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7535 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7536 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7537 sound_dlg[18].d2 = zcmusic_bufsz;
7538 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7539 sound_dlg[20].d2 = pan_style;
7540
7541 int32_t ret = zc_popup_dialog(sound_dlg,1);
7542
7543 if(ret==2)
7544 {
7545 master_volume(digi_volume,midi_volume);
7546
7547 for(int32_t i=0; i<WAV_COUNT; ++i)
7548 {
7549 //allegro assertion fails when passing in -1 as voice -DD
7550 if(sfx_voice[i] > 0)
7551 voice_set_volume(sfx_voice[i], sfx_volume);
7552 }
7553 }
7554 else
7555 {
7556 midi_volume = m;
7557 digi_volume = d;
7558 emusic_volume = e;
7559 zcmusic_bufsz = b;
7560 sfx_volume = s;
7561 pan_style = p;
7562 }
7563
7564 save_game_configs();
7565 return D_O_K;
7566 }
7567
7568 int32_t queding(char const* s1, char const* s2, char const* s3)
7569 {
7570 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7571 }
7572
7573 int32_t onQuit()
7574 {
7575 if(Playing)
7576 {
7577 int32_t ret=0;
7578
7579 if(get_bit(quest_rules, qr_NOCONTINUE))
7580 {
7581 if(standalone_mode)
7582 {
7583 ret=queding("End current game?",
7584 "The continue screen is disabled; the game",
7585 "will be reloaded from the last save.");
7586 }
7587 else
7588 {
7589 ret=queding("End current game?",
7590 "The continue screen is disabled. You will",
7591 "be returned to the file select screen.");
7592 }
7593 }
7594 else
7595 ret=queding("End current game?",NULL,NULL);
7596
7597 if(ret==1)
7598 {
7599 disableClickToFreeze=false;
7600 Quit=qQUIT;
7601
7602 // Trying to evade a door repair charge?
7603 if(repaircharge)
7604 {
7605 game->change_drupy(-repaircharge);
7606 repaircharge=0;
7607 }
7608
7609 return D_CLOSE;
7610 }
7611 }
7612
7613 return D_O_K;
7614 }
7615
7616 int32_t onTryQuitMenu()
7617 {
7618 return onTryQuit(true);
7619 }
7620
7621 int32_t onTryQuit(bool inMenu)
7622 {
7623 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7624 {
7625 if(get_bit(quest_rules,qr_OLD_F6))
7626 {
7627 if(inMenu) onQuit();
7628 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7629 }
7630 else
7631 {
7632 disableClickToFreeze=false;
7633 GameFlags |= GAMEFLAG_TRYQUIT;
7634 }
7635 return D_CLOSE;
7636 }
7637
7638 return D_O_K;
7639 }
7640
7641 int32_t onReset()
7642 {
7643 if(queding(" Reset system? ",NULL,NULL)==1)
7644 {
7645 disableClickToFreeze=false;
7646 Quit=qRESET;
7647 replay_quit();
7648 return D_CLOSE;
7649 }
7650
7651 return D_O_K;
7652 }
7653
7654 int32_t onExit()
7655 {
7656 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7657 {
7658 Quit=qEXIT;
7659 return D_CLOSE;
7660 }
7661
7662 return D_O_K;
7663 }
7664
7665 int32_t onTitle_NES()
7666 {
7667 title_version=0;
7668 return D_O_K;
7669 }
7670 int32_t onTitle_DX()
7671 {
7672 title_version=1;
7673 return D_O_K;
7674 }
7675 int32_t onTitle_25()
7676 {
7677 title_version=2;
7678 return D_O_K;
7679 }
7680
7681 int32_t onDebug()
7682 {
7683 if(debug_enabled)
7684 set_debug(!get_debug());
7685 save_game_configs();
7686 return D_O_K;
7687 }
7688
7689 int32_t onHeartBeep()
7690 {
7691 heart_beep=!heart_beep;
7692 save_game_configs();
7693 return D_O_K;
7694 }
7695
7696 int32_t onSaveIndicator()
7697 {
7698 use_save_indicator=!use_save_indicator;
7699 save_game_configs();
7700 return D_O_K;
7701 }
7702
7703 int32_t onEpilepsy()
7704 {
7705 if(jwin_alert3(
7706 "Epilepsy Flash Reduction",
7707 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7708 "Disabling this will restore standard flash and wavy behaviour.",
7709 "Proceed?",
7710 "&Yes",
7711 "&No",
7712 NULL,
7713 'y',
7714 'n',
7715 0,
7716 lfont) == 1)
7717 {
7718 if ( epilepsyFlashReduction ) epilepsyFlashReduction = 0;
7719 else epilepsyFlashReduction = 1;
7720 set_config_int("zeldadx","checked_epilepsy",1);
7721 save_game_configs();
7722 }
7723 return D_O_K;
7724 }
7725
7726 int32_t onTriforce()
7727 {
7728 for(int32_t i=0; i<MAXINITTABS; ++i)
7729 {
7730 init_tabs[i].flags&=~D_SELECTED;
7731 }
7732
7733 init_tabs[3].flags=D_SELECTED;
7734 return onCheatConsole();
7735 /*triforce_dlg[0].dp2=lfont;
7736 for(int32_t i=1; i<=8; i++)
7737 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7738
7739 if(zc_popup_dialog (triforce_dlg,-1)==9)
7740 {
7741 for(int32_t i=1; i<=8; i++)
7742 {
7743 game->lvlitems[i] &= ~liTRIFORCE;
7744 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7745 }
7746 }
7747 return D_O_K;*/
7748 }
7749
7750 bool rc = false;
7751 /*
7752 int32_t onEquipment()
7753 {
7754 for (int32_t i=0; i<MAXINITTABS; ++i)
7755 {
7756 init_tabs[i].flags&=~D_SELECTED;
7757 }
7758 init_tabs[0].flags=D_SELECTED;
7759 return onCheatConsole();
7760 }
7761 */
7762
7763 int32_t onItems()
7764 {
7765 for(int32_t i=0; i<MAXINITTABS; ++i)
7766 {
7767 init_tabs[i].flags&=~D_SELECTED;
7768 }
7769
7770 init_tabs[1].flags=D_SELECTED;
7771 return onCheatConsole();
7772 }
7773
7774 static DIALOG getnum_dlg[] =
7775 {
7776 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7777 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7778 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7779 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7780 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7781 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7782 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7783 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7784 };
7785
7786 int32_t getnumber(const char *prompt,int32_t initialval)
7787 {
7788 char buf[20];
7789 sprintf(buf,"%d",initialval);
7790 getnum_dlg[0].dp=(void *)prompt;
7791 getnum_dlg[0].dp2=lfont;
7792 getnum_dlg[2].dp=buf;
7793
7794 if(is_large)
7795 large_dialog(getnum_dlg);
7796
7797 if(zc_popup_dialog(getnum_dlg,2)==3)
7798 return atoi(buf);
7799
7800 return initialval;
7801 }
7802
7803 int32_t onLife()
7804 {
7805 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7806 cheats_enqueue(Cheat::Life, value);
7807 return D_O_K;
7808 }
7809
7810 int32_t onHeartC()
7811 {
7812 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7813 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7814 cheats_enqueue(Cheat::MaxLife, max_life);
7815 cheats_enqueue(Cheat::Life, life);
7816 return D_O_K;
7817 }
7818
7819 int32_t onMagicC()
7820 {
7821 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7822 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7823 cheats_enqueue(Cheat::MaxMagic, max_magic);
7824 cheats_enqueue(Cheat::Magic, magic);
7825 return D_O_K;
7826 }
7827
7828 int32_t onRupies()
7829 {
7830 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7831 cheats_enqueue(Cheat::Rupies, value);
7832 return D_O_K;
7833 }
7834
7835 int32_t onMaxBombs()
7836 {
7837 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7838 cheats_enqueue(Cheat::MaxBombs, value);
7839 cheats_enqueue(Cheat::Bombs, value);
7840 return D_O_K;
7841 }
7842
7843 int32_t onRefillLife()
7844 {
7845 cheats_enqueue(Cheat::Life, game->get_maxlife());
7846 return D_O_K;
7847 }
7848 int32_t onRefillMagic()
7849 {
7850 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7851 return D_O_K;
7852 }
7853 int32_t onClock()
7854 {
7855 cheats_enqueue(Cheat::Clock);
7856 return D_O_K;
7857 }
7858
7859 int32_t onQstPath()
7860 {
7861 char path[2048];
7862
7863 chop_path(qstdir);
7864 strcpy(path,qstdir);
7865
7866 go();
7867
7868 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7869 {
7870 chop_path(path);
7871 fix_filename_case(path);
7872 fix_filename_slashes(path);
7873 strcpy(qstdir,path);
7874 strcpy(qstpath,qstdir);
7875 }
7876
7877 comeback();
7878 return D_O_K;
7879 }
7880
7881 #include "dialog/cheat_dialog.h"
7882 int32_t onCheat()
7883 {
7884 call_setcheat_dialog();
7885 game->set_cheat(maxcheat);
7886 if(cheat) game->did_cheat(true);
7887 return D_O_K;
7888 }
7889
7890 int32_t onCheatRupies()
7891 {
7892 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7893 return D_O_K;
7894 }
7895
7896 int32_t onCheatArrows()
7897 {
7898 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7899 return D_O_K;
7900 }
7901
7902 int32_t onCheatBombs()
7903 {
7904 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7905 return D_O_K;
7906 }
7907
7908 // *** screen saver
7909
7910 3512 int32_t after_time()
7911 {
7912
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(ss_enable == 0)
7913 return INT_MAX;
7914
7915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
3512 if(ss_after <= 0)
7916 return 5 * 60;
7917
7918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
3512 if(ss_after <= 3)
7919 return ss_after * 15 * 60;
7920
7921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
3512 if(ss_after <= 13)
7922 return (ss_after - 3) * 60 * 60;
7923
7924 3512 return MAX_IDLE + 1;
7925 3512 }
7926
7927 static const char *after_str[15] =
7928 {
7929 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7930 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7931 "Never"
7932 };
7933
7934 const char *after_list(int32_t index, int32_t *list_size)
7935 {
7936 if(index < 0)
7937 {
7938 *list_size = 15;
7939 return NULL;
7940 }
7941
7942 return after_str[index];
7943 }
7944
7945 11 static ListData after__list(after_list, &font);
7946
7947 static DIALOG scrsaver_dlg[] =
7948 {
7949 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7950 11 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7951 11 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7952 11 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7953 11 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7954 11 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7955 11 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7956 11 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7957 11 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7958 11 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7959 11 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7960 11 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7961 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7962 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7963 };
7964
7965 int32_t onScreenSaver()
7966 {
7967 scrsaver_dlg[0].dp2=lfont;
7968 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = ss_after;
7969 scrsaver_dlg[6].d2 = ss_speed;
7970 scrsaver_dlg[7].d2 = ss_density;
7971
7972 if(is_large)
7973 large_dialog(scrsaver_dlg);
7974
7975 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7976
7977 if(ret == 8 || ret == 9)
7978 {
7979 ss_after = scrsaver_dlg[5].d1;
7980 ss_speed = scrsaver_dlg[6].d2;
7981 ss_density = scrsaver_dlg[7].d2;
7982 }
7983
7984 if(ret == 9)
7985 // preview Screen Saver
7986 {
7987 clear_keybuf();
7988 scare_mouse();
7989 Matrix(ss_speed, ss_density, 30);
7990 system_pal();
7991 unscare_mouse();
7992 }
7993
7994 return D_O_K;
7995 }
7996
7997 /***** Menus *****/
7998
7999 static MENU game_menu[] =
8000 {
8001 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
8002 { (char *)"", NULL, NULL, 0, NULL },
8003 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
8004 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
8005 { (char *)"", NULL, NULL, 0, NULL },
8006 #ifdef __EMSCRIPTEN__
8007 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
8008 #elif defined(ALLEGRO_MACOSX)
8009 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
8010 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
8011 #else
8012 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
8013 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
8014 #endif
8015 { NULL, NULL, NULL, 0, NULL }
8016 };
8017
8018 static MENU title_menu[] =
8019 {
8020 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
8021 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
8022 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
8023 { NULL, NULL, NULL, 0, NULL }
8024 };
8025
8026 static MENU snapshot_format_menu[] =
8027 {
8028 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
8029 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
8030 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
8031 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
8032 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
8033 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
8034 { NULL, NULL, NULL, 0, NULL }
8035 };
8036
8037 static MENU controls_menu[] =
8038 {
8039 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
8040 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
8041 { NULL, NULL, NULL, 0, NULL }
8042 };
8043
8044 static MENU name_entry_mode_menu[] =
8045 {
8046 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
8047 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
8048 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
8049 { NULL, NULL, NULL, 0, NULL }
8050 };
8051
8052 static void set_controls_menu_active()
8053 {
8054
8055 }
8056
8057 static MENU settings_menu[] =
8058 {
8059 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
8060 { (char *)"&Sound...", onSound, NULL, 0, NULL },
8061 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
8062 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
8063 { (char *)"", NULL, NULL, 0, NULL },
8064 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
8065 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
8066 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
8067 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
8068 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
8069 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
8070 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
8071 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
8072 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
8073 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
8074 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
8075 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
8076 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
8077 { (char *)"", NULL, NULL, 0, NULL },
8078 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
8079 { (char *)"", NULL, NULL, 0, NULL },
8080 { NULL, NULL, NULL, 0, NULL }
8081 };
8082
8083
8084 static MENU misc_menu[] =
8085 {
8086 { (char *)"&About...", onAbout, NULL, 0, NULL },
8087 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
8088 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
8089 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
8090 { (char *)"", NULL, NULL, 0, NULL },
8091 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
8092 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
8093 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
8094 { (char *)"", NULL, NULL, 0, NULL },
8095 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
8096 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
8097 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
8098 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
8099 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
8100 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
8101 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
8102 { (char *)"Replay", NULL, replay_menu, 0, NULL },
8103
8104 { NULL, NULL, NULL, 0, NULL }
8105 };
8106
8107 static MENU refill_menu[] =
8108 {
8109 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
8110 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
8111 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
8112 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
8113 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
8114 { NULL, NULL, NULL, 0, NULL }
8115 };
8116
8117 static MENU show_menu[] =
8118 {
8119 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
8120 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
8121 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
8122 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
8123 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
8124 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
8125 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
8126 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
8127 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
8128 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
8129 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
8130 { (char *)"", NULL, NULL, 0, NULL },
8131 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
8132 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
8133 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
8134 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
8135 { NULL, NULL, NULL, 0, NULL }
8136 };
8137
8138 static MENU cheat_menu[] =
8139 {
8140 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
8141 { (char *)"", NULL, NULL, 0, NULL },
8142 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
8143 { (char *)"", NULL, NULL, 0, NULL },
8144 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
8145 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
8146 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
8147 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
8148 { (char *)"", NULL, NULL, 0, NULL },
8149 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
8150 { (char *)"", NULL, NULL, 0, NULL },
8151 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
8152 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
8153 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
8154 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
8155 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
8156 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
8157 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
8158 { NULL, NULL, NULL, 0, NULL }
8159 };
8160
8161 static MENU fixes_menu[] =
8162 {
8163 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
8164 { NULL, NULL, NULL, 0, NULL }
8165 };
8166
8167 #if DEVLEVEL > 0
8168 int32_t devLogging();
8169 int32_t devDebug();
8170 int32_t devTimestmp();
8171 #if DEVLEVEL > 1
8172 int32_t setCheat();
8173 #endif //DEVLEVEL > 1
8174 static MENU dev_menu[] =
8175 {
8176 { (char *)"&Force Error Log", devLogging, NULL, D_SELECTED, NULL },
8177 { (char *)"&Extra Debug Log", devDebug, NULL, D_SELECTED, NULL },
8178 { (char *)"&Timestamp Log", devTimestmp, NULL, D_SELECTED, NULL },
8179 #if DEVLEVEL > 1
8180 { (char *)"", NULL, NULL, 0, NULL },
8181 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8182 #endif //DEVLEVEL > 1
8183 { NULL, NULL, NULL, 0, NULL }
8184 };
8185 int32_t devLogging()
8186 {
8187 dev_logging = !dev_logging;
8188 dev_menu[0].flags = dev_logging ? D_SELECTED : 0;
8189 return D_O_K;
8190 }
8191 int32_t devDebug()
8192 {
8193 dev_debug = !dev_debug;
8194 dev_menu[1].flags = dev_debug ? D_SELECTED : 0;
8195 return D_O_K;
8196 }
8197 int32_t devTimestmp()
8198 {
8199 dev_timestmp = !dev_timestmp;
8200 dev_menu[2].flags = dev_timestmp ? D_SELECTED : 0;
8201 return D_O_K;
8202 }
8203 #if DEVLEVEL > 1
8204 int32_t setCheat()
8205 {
8206 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8207 return D_O_K;
8208 }
8209 #endif //DEVLEVEL > 1
8210 #endif //DEVLEVEL > 0
8211
8212 MENU the_player_menu[] =
8213 {
8214 { (char *)"&Game", NULL, game_menu, 0, NULL },
8215 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8216 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8217 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8218 #if DEVLEVEL > 0
8219 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8220 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8221 { NULL, NULL, NULL, 0, NULL }
8222 #else
8223 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8224 { NULL, NULL, NULL, 0, NULL }
8225 #endif
8226 };
8227
8228 MENU the_player_menu2[] =
8229 {
8230 { (char *)"&Game", NULL, game_menu, 0, NULL },
8231 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8232 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8233
8234 #if DEVLEVEL > 0
8235 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8236 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8237 { NULL, NULL, NULL, 0, NULL }
8238 #else
8239 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8240 { NULL, NULL, NULL, 0, NULL }
8241 #endif
8242
8243 };
8244
8245 int32_t onMIDIPatch()
8246 {
8247 if(jwin_alert3(
8248 "Toggle Windows MIDI Fix",
8249 "This action will change whether ZC Player auto-restarts a MIDI at its",
8250 "last index if you move ZC Player out of focus, then back into focus.",
8251 "Proceed?",
8252 "&Yes",
8253 "&No",
8254 NULL,
8255 'y',
8256 'n',
8257 0,
8258 lfont) == 1)
8259 {
8260 if (midi_patch_fix) midi_patch_fix = 0;
8261
8262 else midi_patch_fix = 1;
8263
8264 }
8265 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8266 save_game_configs();
8267 return D_O_K;
8268 }
8269
8270 int32_t onKeyboardEntry()
8271 {
8272 NameEntryMode=0;
8273 return D_O_K;
8274 }
8275
8276 int32_t onLetterGridEntry()
8277 {
8278 NameEntryMode=1;
8279 return D_O_K;
8280 }
8281
8282 int32_t onExtLetterGridEntry()
8283 {
8284 NameEntryMode=2;
8285 return D_O_K;
8286 }
8287
8288 int32_t onFullscreenMenu()
8289 {
8290 onFullscreen();
8291 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8292 return D_O_K;
8293 }
8294
8295 11 void fix_menu()
8296 {
8297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!debug_enabled)
8298 11 settings_menu[18].text = NULL;
8299 11 }
8300
8301 static DIALOG system_dlg[] =
8302 {
8303 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8304 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8305 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8306 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8307 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8308 #ifndef ALLEGRO_MACOSX
8309 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8310 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8311 #else
8312 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8313 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8314 #endif
8315 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8316 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8317 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8318 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8319 };
8320
8321 static DIALOG system_dlg2[] =
8322 {
8323 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8324 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8325 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8326 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8327 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8328 #ifndef ALLEGRO_MACOSX
8329 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8330 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8331 #else
8332 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8333 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8334 #endif
8335 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8336 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8337 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8338 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8339 };
8340
8341 void reset_snapshot_format_menu()
8342 {
8343 for(int32_t i=0; i<ssfmtMAX; ++i)
8344 {
8345 snapshot_format_menu[i].flags=0;
8346 }
8347 }
8348
8349 int32_t onSetSnapshotFormat()
8350 {
8351 switch(active_menu->text[1])
8352 {
8353 case 'B': //"&BMP"
8354 SnapshotFormat=0;
8355 break;
8356
8357 case 'G': //"&GIF"
8358 SnapshotFormat=1;
8359 break;
8360
8361 case 'J': //"&JPG"
8362 SnapshotFormat=2;
8363 break;
8364
8365 case 'P': //"&PNG"
8366 SnapshotFormat=3;
8367 break;
8368
8369 case 'C': //"PC&X"
8370 SnapshotFormat=4;
8371 break;
8372
8373 case 'T': //"&TGA"
8374 SnapshotFormat=5;
8375 break;
8376
8377 case 'L': //"&LBM"
8378 SnapshotFormat=6;
8379 break;
8380 }
8381
8382 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8383 return D_O_K;
8384 }
8385
8386
8387 11 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8388 {
8389 PALETTE tmp;
8390
8391
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<256; i++)
8392 {
8393 2816 tmp[i].r=r;
8394 2816 tmp[i].g=g;
8395 2816 tmp[i].b=b;
8396 2816 }
8397
8398 11 fade_interpolate(src,tmp,dest,pos,from,to);
8399 11 }
8400
8401 11 void system_pal()
8402 {
8403 11 is_sys_pal = true;
8404 static PALETTE pal;
8405 11 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8406
8407 // set up the grayscale palette
8408
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 11 times.
715 for(int32_t i=128; i<192; i++)
8409 {
8410 704 pal[i].r = i-128;
8411 704 pal[i].g = i-128;
8412 704 pal[i].b = i-128;
8413 704 }
8414 11 load_colorset(gui_colorset, pal);
8415
8416 11 color_layer(pal, pal, 24,16,16, 28, 128,191);
8417
8418
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 11 times.
1419 for(int32_t i=0; i<256; i+=2)
8419 {
8420 1408 int32_t v = (i>>3)+2;
8421 1408 int32_t c = (i>>3)+192;
8422 1408 pal[c] = _RGB(v,v,v+(v>>1));
8423 /*
8424 if(i<240)
8425 {
8426 _allegro_hline(tmp_scr,0,i,319,c);
8427 _allegro_hline(tmp_scr,0,i+1,319,c);
8428 }
8429 */
8430 1408 }
8431
8432 // draw the vertical screen gradient
8433
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 11 times.
2651 for(int32_t i=0; i<240; ++i)
8434 {
8435 2640 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8436 2640 }
8437
8438 /*
8439 palrstart= 10*63/255; palrend=166*63/255;
8440 palgstart= 36*63/255; palgend=202*63/255;
8441 palbstart=106*63/255; palbend=240*63/255;
8442 paldivs=32;
8443 for(int32_t i=0; i<paldivs; i++)
8444 {
8445 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8446 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8447 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8448 }
8449 */
8450 11 BITMAP *panorama = create_bitmap_ex(8,256,224);
8451 int32_t ts_height, ts_start;
8452
8453
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8454 {
8455 clear_to_color(panorama,0);
8456 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8457 ts_height=224-passive_subscreen_height;
8458 ts_start=28;
8459 }
8460 else
8461 {
8462 11 blit(framebuf,panorama,0,0,0,0,256,224);
8463 11 ts_height=224;
8464 11 ts_start=0;
8465 }
8466
8467 // gray scale the current frame
8468
2/2
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 11 times.
2475 for(int32_t y=0; y<ts_height; y++)
8469 {
8470
2/2
✓ Branch 0 taken 630784 times.
✓ Branch 1 taken 2464 times.
633248 for(int32_t x=0; x<256; x++)
8471 {
8472 630784 int32_t c = panorama->line[y+ts_start][x];
8473
1/2
✓ Branch 0 taken 630784 times.
✗ Branch 1 not taken.
630784 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8474 630784 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8475 630784 }
8476 2464 }
8477
8478 11 destroy_bitmap(panorama);
8479
8480 // save the fps_undo section
8481 11 blit(tmp_scr,fps_undo,40,216,0,0,64,16);
8482
8483 // display everything
8484 11 vsync();
8485 11 hw_palette = &pal;
8486 11 update_hw_pal = true;
8487
8488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(sbig)
8489 stretch_blit(tmp_scr,screen,0,0,320,240,scrx-(160*(screen_scale-1)),scry-(120*(screen_scale-1)),screen_scale*320,screen_scale*240);
8490 else
8491 11 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8492
8493
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(ShowFPS)
8494 show_fps(screen);
8495
8496
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(Paused)
8497 show_paused(screen);
8498
8499 // sys_pal = pal;
8500 11 memcpy(sys_pal,pal,sizeof(pal));
8501 11 }
8502
8503 void system_pal2()
8504 {
8505 is_sys_pal = true;
8506 static PALETTE RAMpal2;
8507 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8508
8509 /* Windows 2000 colors
8510 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8511 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8512 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8513 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8514 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8515 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8516 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8517 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8518
8519 byte palrstart= 10*63/255, palrend=166*63/255,
8520 palgstart= 36*63/255, palgend=202*63/255,
8521 palbstart=106*63/255, palbend=240*63/255,
8522 paldivs=7;
8523 for(int32_t i=0; i<paldivs; i++)
8524 {
8525 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8526 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8527 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8528 }
8529 */
8530
8531 /* Windows 98 colors
8532 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8533 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8534 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8535 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8536 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8537 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8538 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8539 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8540
8541 byte palrstart= 0*63/255, palrend=166*63/255,
8542 palgstart= 0*63/255, palgend=202*63/255,
8543 palbstart=128*63/255, palbend=240*63/255,
8544 paldivs=7;
8545 for(int32_t i=0; i<paldivs; i++)
8546 {
8547 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8548 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8549 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8550 }
8551 */
8552
8553 /* Windows 99 colors
8554 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8555 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8556 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8557 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8558 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8559 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8560 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8561 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8562 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8563
8564 byte palrstart= 0*63/255, palrend=166*63/255,
8565 palgstart= 0*63/255, palgend=202*63/255,
8566
8567 palbstart=128*63/255, palbend=240*63/255,
8568 paldivs=6;
8569 for(int32_t i=0; i<paldivs; i++)
8570 {
8571 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8572 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8573 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8574 }
8575 */
8576
8577
8578
8579 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8580 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8581 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8582 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8583 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8584 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8585 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8586 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8587 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8588
8589 byte palrstart= 0*63/255, palrend=166*63/255,
8590 palgstart= 0*63/255, palgend=202*63/255,
8591 palbstart=128*63/255, palbend=240*63/255,
8592 paldivs=6;
8593
8594 for(int32_t i=0; i<paldivs; i++)
8595 {
8596 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8597 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8598 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8599 }
8600
8601 gui_bg_color=jwin_pal[jcBOX];
8602 gui_fg_color=jwin_pal[jcBOXFG];
8603
8604 jwin_set_colors(jwin_pal);
8605
8606
8607 // set up the new palette
8608 for(int32_t i=128; i<192; i++)
8609 {
8610 RAMpal2[i].r = i-128;
8611 RAMpal2[i].g = i-128;
8612 RAMpal2[i].b = i-128;
8613 }
8614
8615 /*
8616 for(int32_t i=0; i<64; i++)
8617 {
8618 RAMpal2[128+i] = _RGB(i,i,i)1));
8619 }
8620 */
8621
8622 /*
8623
8624 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8625 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8626 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8627 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8628 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8629 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8630 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8631
8632 gui_fg_color=vc(14);
8633 gui_bg_color=vc(1);
8634
8635 jwin_set_colors(jwin_pal);
8636 */
8637
8638 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8639
8640 // set up the colors for the vertical screen gradient
8641 for(int32_t i=0; i<256; i+=2)
8642 {
8643 int32_t v = (i>>3)+2;
8644 int32_t c = (i>>3)+192;
8645 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8646
8647 /*
8648 if(i<240)
8649 {
8650 _allegro_hline(tmp_scr,0,i,319,c);
8651 _allegro_hline(tmp_scr,0,i+1,319,c);
8652 }
8653 */
8654 }
8655
8656 // hw_palette = &RAMpal;
8657 // update_hw_pal = true;
8658
8659 for(int32_t i=0; i<240; ++i)
8660 {
8661 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8662 }
8663
8664 /*
8665 byte palrstart= 10*63/255, palrend=166*63/255,
8666 palgstart= 36*63/255, palgend=202*63/255,
8667 palbstart=106*63/255, palbend=240*63/255,
8668 paldivs=32;
8669 for(int32_t i=0; i<paldivs; i++)
8670 {
8671 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8672 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8673 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8674 }
8675 */
8676 BITMAP *panorama = create_bitmap_ex(8,256,224);
8677 int32_t ts_height, ts_start;
8678
8679 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8680 {
8681 clear_to_color(panorama,0);
8682 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8683 ts_height=224-passive_subscreen_height;
8684 ts_start=28;
8685 }
8686 else
8687 {
8688 blit(framebuf,panorama,0,0,0,0,256,224);
8689 ts_height=224;
8690 ts_start=0;
8691 }
8692
8693 // gray scale the current frame
8694 for(int32_t y=0; y<ts_height; y++)
8695 {
8696 for(int32_t x=0; x<256; x++)
8697 {
8698 int32_t c = panorama->line[y+ts_start][x];
8699 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8700 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8701 }
8702 }
8703
8704 destroy_bitmap(panorama);
8705
8706 // save the fps_undo section
8707 blit(tmp_scr,fps_undo,40,216,0,0,64,16);
8708
8709 // display everything
8710 vsync();
8711 hw_palette = &RAMpal2;
8712 update_hw_pal = true;
8713
8714 if(sbig)
8715 //stretch_blit(tmp_scr,screen,0,0,320,240,scrx-160,scry-120,640,480);
8716 stretch_blit(tmp_scr,screen,0,0,320,240,scrx-(160*(screen_scale-1)),scry-(120*(screen_scale-1)),screen_scale*320,screen_scale*240);
8717 else
8718 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8719
8720 if(ShowFPS)
8721 show_fps(screen);
8722
8723 if(Paused)
8724 show_paused(screen);
8725
8726 // sys_pal = pal;
8727 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8728 }
8729
8730 static uint32_t entered_sys_pal = 0;
8731 void enter_sys_pal()
8732 {
8733 if(is_sys_pal)
8734 {
8735 if(entered_sys_pal)
8736 ++entered_sys_pal;
8737 return;
8738 }
8739 system_pal();
8740 ++entered_sys_pal;
8741 }
8742 void exit_sys_pal()
8743 {
8744 if(entered_sys_pal)
8745 {
8746 if(!--entered_sys_pal)
8747 {
8748 game_pal();
8749 }
8750 }
8751 }
8752
8753 void switch_out_callback()
8754 {
8755 if (pause_in_background)
8756 {
8757 callback_switchin = 3;
8758 return;
8759 }
8760
8761 #ifdef _WIN32
8762 if(midi_patch_fix==0 || currmidi==-1)
8763 return;
8764
8765
8766 paused_midi_pos = midi_pos;
8767 zc_stop_midi();
8768 midi_paused=true;
8769 midi_suspended = midissuspHALTED;
8770 #endif
8771 }
8772
8773 void switch_in_callback()
8774 {
8775 if(pause_in_background)
8776 {
8777 return;
8778 }
8779
8780 #ifdef _WIN32
8781 if(midi_patch_fix==0 || currmidi==-1)
8782 return;
8783
8784 else
8785 {
8786 callback_switchin = 1;
8787 midi_suspended = midissuspRESUME;
8788 }
8789 #endif
8790 }
8791
8792 15 void game_pal()
8793 {
8794 15 is_sys_pal = false;
8795 15 entered_sys_pal = 0;
8796 15 clear_to_color(screen,BLACK);
8797 15 hw_palette = &RAMpal;
8798 15 update_hw_pal = true;
8799 15 }
8800
8801 static char bar_str[] = "";
8802
8803 void music_pause()
8804 {
8805 //al_pause_duh(tmplayer);
8806 zcmusic_pause(zcmusic, ZCM_PAUSE);
8807 zc_midi_pause();
8808 midi_paused=true;
8809 }
8810
8811 void music_resume()
8812 {
8813 //al_resume_duh(tmplayer);
8814 zcmusic_pause(zcmusic, ZCM_RESUME);
8815 zc_midi_resume();
8816 midi_paused=false;
8817 }
8818
8819 12 void music_stop()
8820 {
8821 //al_stop_duh(tmplayer);
8822 //unload_duh(tmusic);
8823 //tmusic=NULL;
8824 //tmplayer=NULL;
8825 12 zcmusic_stop(zcmusic);
8826 12 zcmusic_unload_file(zcmusic);
8827 12 zc_stop_midi();
8828 12 midi_paused=false;
8829 12 currmidi=-1;
8830 12 }
8831
8832 void System()
8833 {
8834 mouse_down=gui_mouse_b();
8835 music_pause();
8836 pause_all_sfx();
8837 MenuOpen = true;
8838 system_pal();
8839 // FONT *oldfont=font;
8840 // font=tfont;
8841
8842 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8843
8844 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8845 #if DEVLEVEL > 1
8846 dev_menu[4].flags = Playing ? 0 : D_DISABLED;
8847 #endif
8848 game_menu[3].flags =
8849 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8850 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8851 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8852 clear_keybuf();
8853 show_mouse(screen);
8854
8855 DIALOG_PLAYER *p;
8856
8857 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8858 {
8859 p = init_dialog(system_dlg2,-1);
8860 }
8861 else
8862 {
8863 p = init_dialog(system_dlg,-1);
8864 }
8865
8866 // drop the menu on startup if menu button pressed
8867 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8868 simulate_keypress(KEY_G << 8);
8869
8870 do
8871 {
8872 rest(17);
8873
8874 if(mouse_down && !gui_mouse_b())
8875 mouse_down=0;
8876
8877 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8878 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8879 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8880
8881 settings_menu[0].flags = replay_is_replaying() ? D_DISABLED : 0;
8882 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8883 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8884 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8885 settings_menu[8].flags = NESquit?D_SELECTED:0;
8886 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8887 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8888 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8889 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8890 settings_menu[13].flags = volkeys?D_SELECTED:0;
8891 //Epilepsy Prevention
8892 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8893
8894 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8895 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8896 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8897
8898 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8899 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8900
8901 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8902 cheat_menu[0].flags = 0;
8903 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8904 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8905 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8906 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8907 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8908 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8909 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8910 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8911 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8912
8913 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8914 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8915 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8916 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8917 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8918 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8919 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8920 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8921 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8922 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8923 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8924 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8925 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8926 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8927 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8928
8929 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8930 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8931
8932 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8933 (char *)"Disable recording new saves" :
8934 (char *)"Enable recording new saves";
8935 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8936 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8937 (char *)"Stop recording" :
8938 (char *)"Stop replaying";
8939 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8940
8941 reset_snapshot_format_menu();
8942 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8943
8944 if(debug_enabled)
8945 {
8946 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8947 }
8948
8949 if(gui_mouse_b() && !mouse_down)
8950 break;
8951
8952 // press menu to drop the menu
8953 if(rMbtn())
8954 simulate_keypress(KEY_G << 8);
8955
8956 {
8957 if(input_idle(true) > after_time())
8958 // run Screeen Saver
8959 {
8960 // Screen saver enabled for now.
8961 clear_keybuf();
8962 scare_mouse();
8963 Matrix(ss_speed, ss_density, 0);
8964 system_pal();
8965 unscare_mouse();
8966 broadcast_dialog_message(MSG_DRAW, 0);
8967 }
8968 }
8969 update_hw_screen();
8970 }
8971 while(update_dialog(p));
8972
8973 // font=oldfont;
8974 mouse_down=gui_mouse_b();
8975 shutdown_dialog(p);
8976 show_mouse(NULL);
8977 MenuOpen = false;
8978 if(Quit)
8979 {
8980 kill_sfx();
8981 music_stop();
8982 clear_to_color(screen,BLACK);
8983 update_hw_screen();
8984 }
8985 else
8986 {
8987 game_pal();
8988 music_resume();
8989 resume_all_sfx();
8990
8991 if(rc)
8992 ringcolor(false);
8993 }
8994
8995 eat_buttons();
8996
8997 rc=false;
8998 clear_keybuf();
8999 // text_mode(0);
9000 }
9001
9002 void fix_dialog(DIALOG *d)
9003 {
9004 for(; d->proc != NULL; d++)
9005 {
9006 d->x += scrx;
9007 d->y += scry;
9008 }
9009 }
9010
9011 11 void fix_dialogs()
9012 {
9013 /*
9014 int32_t x = scrx-(sbig?160:0);
9015 int32_t y = scry-(sbig?120:0);
9016 if(x>0) x+=3;
9017 if(y>0) y+=3;
9018 if(x<0) x=0;
9019 if(y<0) y=0;
9020
9021 system_dlg[0].x = x;
9022 system_dlg[0].y = y;
9023 system_dlg2[0].x = x;
9024 system_dlg2[0].y = y;
9025 */
9026
9027 11 jwin_center_dialog(about_dlg);
9028 11 jwin_center_dialog(gamepad_dlg);
9029 11 jwin_center_dialog(credits_dlg);
9030 11 jwin_center_dialog(gamemode_dlg);
9031 11 jwin_center_dialog(getnum_dlg);
9032 11 jwin_center_dialog(goto_dlg);
9033 11 jwin_center_dialog(keyboard_control_dlg);
9034 11 jwin_center_dialog(midi_dlg);
9035 11 jwin_center_dialog(quest_dlg);
9036 11 jwin_center_dialog(scrsaver_dlg);
9037 11 jwin_center_dialog(sound_dlg);
9038 11 jwin_center_dialog(triforce_dlg);
9039
9040 11 digi_dp[1] += scrx;
9041 11 digi_dp[2] += scry;
9042 11 midi_dp[1] += scrx;
9043 11 midi_dp[2] += scry;
9044 11 pan_dp[1] += scrx;
9045 11 pan_dp[2] += scry;
9046 11 emus_dp[1] += scrx;
9047 11 emus_dp[2] += scry;
9048 11 buf_dp[1] += scrx;
9049 11 buf_dp[2] += scry;
9050 11 sfx_dp[1] += scrx;
9051 11 sfx_dp[2] += scry;
9052 11 }
9053
9054 /*****************************/
9055 /**** Custom Sound System ****/
9056 /*****************************/
9057
9058 11 INLINE int32_t mixvol(int32_t v1,int32_t v2)
9059 {
9060
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
9061 }
9062
9063 // Run an NSF, or a MIDI if the NSF is missing somehow.
9064 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
9065 {
9066 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
9067
9068 // Found it
9069 if(newzcmusic!=NULL)
9070 {
9071 zcmusic_stop(zcmusic);
9072 zcmusic_unload_file(zcmusic);
9073 zc_stop_midi();
9074
9075 zcmusic=newzcmusic;
9076 zcmusic_play(zcmusic, emusic_volume);
9077
9078 if(track>0)
9079 zcmusic_change_track(zcmusic,track);
9080
9081 return true;
9082 }
9083
9084 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
9085 else if(midi>-1000)
9086 jukebox(midi);
9087
9088 return false;
9089 }
9090
9091 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
9092 {
9093 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
9094 // Found it
9095 if(newzcmusic!=NULL)
9096 {
9097 zcmusic_stop(zcmusic);
9098 zcmusic_unload_file(zcmusic);
9099 zc_stop_midi();
9100
9101 zcmusic=newzcmusic;
9102 zcmusic_play(zcmusic, emusic_volume);
9103
9104 if(track>0)
9105 zcmusic_change_track(zcmusic,track);
9106
9107 return true;
9108 }
9109
9110 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
9111 else if(midi>-1000)
9112 jukebox(midi);
9113
9114 return false;
9115 }
9116
9117 int32_t get_zcmusicpos()
9118 {
9119 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
9120 return debugtracething;
9121 return 0;
9122 }
9123
9124 void set_zcmusicpos(int32_t position)
9125 {
9126 zcmusic_set_curpos(zcmusic, position);
9127 }
9128
9129 void set_zcmusicspeed(int32_t speed)
9130 {
9131 int32_t newspeed = vbound(speed, 0, 10000);
9132 zcmusic_set_speed(zcmusic, newspeed);
9133 }
9134
9135 void jukebox(int32_t index,int32_t loop)
9136 {
9137 music_stop();
9138
9139 if(index<0) index=MAXMIDIS-1;
9140
9141 if(index>=MAXMIDIS) index=0;
9142
9143 music_stop();
9144
9145 // Allegro's DIGMID driver (the one normally used on on Linux) gets
9146 // stuck notes when a song stops. This fixes it.
9147 if(strcmp(midi_driver->name, "DIGMID")==0)
9148 zc_set_volume(0, 0);
9149
9150 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
9151 zc_play_midi((MIDI*)tunes[index].data,loop);
9152
9153 if(tunes[index].start>0)
9154 zc_midi_seek(tunes[index].start);
9155
9156 midi_loop_start = tunes[index].loop_start;
9157 midi_loop_end = tunes[index].loop_end;
9158
9159 currmidi=index;
9160 master_volume(digi_volume,midi_volume);
9161 midi_paused=false;
9162 }
9163
9164 void jukebox(int32_t index)
9165 {
9166 if(index<0) index=MAXMIDIS-1;
9167
9168 if(index>=MAXMIDIS) index=0;
9169
9170 // do nothing if it's already playing
9171 if(index==currmidi && midi_pos>=0)
9172 {
9173 midi_paused=false;
9174 return;
9175 }
9176
9177 jukebox(index,tunes[index].loop);
9178 }
9179
9180 8 void play_DmapMusic()
9181 {
9182 static char tfile[2048];
9183 static int32_t ttrack=0;
9184 8 bool domidi=false;
9185
9186
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(DMaps[currdmap].tmusic[0]!=0)
9187 {
9188
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
11 if(zcmusic==NULL ||
9189
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
9190
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
9191 {
9192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(zcmusic != NULL)
9193 {
9194 zcmusic_stop(zcmusic);
9195 zcmusic_unload_file(zcmusic);
9196 zcmusic = NULL;
9197 }
9198
9199 5 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
9200
9201
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(zcmusic!=NULL)
9202 {
9203 5 zc_stop_midi();
9204 5 strcpy(tfile,DMaps[currdmap].tmusic);
9205 5 zcmusic_play(zcmusic, emusic_volume);
9206 5 int32_t temptracks=0;
9207 5 temptracks=zcmusic_get_tracks(zcmusic);
9208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 temptracks=(temptracks<2)?1:temptracks;
9209 5 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
9210 5 zcmusic_change_track(zcmusic,ttrack);
9211 5 }
9212 else
9213 {
9214 tfile[0] = 0;
9215 domidi=true;
9216 }
9217 5 }
9218 8 }
9219 else
9220 {
9221 domidi=true;
9222 }
9223
9224
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(domidi)
9225 {
9226 int32_t m=DMaps[currdmap].midi;
9227
9228 switch(m)
9229 {
9230 case 1:
9231 jukebox(ZC_MIDI_OVERWORLD);
9232 break;
9233
9234 case 2:
9235 jukebox(ZC_MIDI_DUNGEON);
9236 break;
9237
9238 case 3:
9239 jukebox(ZC_MIDI_LEVEL9);
9240 break;
9241
9242 default:
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9244 jukebox(m+MIDIOFFSET_DMAP);
9245 else
9246 music_stop();
9247 }
9248 }
9249 8 }
9250
9251 8 void playLevelMusic()
9252 {
9253 8 int32_t m=tmpscr->screen_midi;
9254
9255
1/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8 switch(m)
9256 {
9257 case -2:
9258 music_stop();
9259 break;
9260
9261 case -1:
9262 8 play_DmapMusic();
9263 8 break;
9264
9265 case 1:
9266 jukebox(ZC_MIDI_OVERWORLD);
9267 break;
9268
9269 case 2:
9270 jukebox(ZC_MIDI_DUNGEON);
9271 break;
9272
9273 case 3:
9274 jukebox(ZC_MIDI_LEVEL9);
9275 break;
9276
9277 default:
9278 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9279 jukebox(m+MIDIOFFSET_MAPSCR);
9280 else
9281 music_stop();
9282 }
9283 8 }
9284
9285 11 void master_volume(int32_t dv,int32_t mv)
9286 {
9287
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
11 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9288
9289
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
11 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9290
9291
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
11 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9292 11 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9293 11 }
9294
9295 /*****************/
9296 /***** SFX *****/
9297 /*****************/
9298
9299 // array of voices, one for each sfx sample in the data file
9300 // 0+ = voice #
9301 // -1 = voice not allocated
9302 11 void Z_init_sound()
9303 {
9304
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<WAV_COUNT; i++)
9305 2816 sfx_voice[i]=-1;
9306
9307
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 11 times.
88 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9308 77 tunes[i].data = (MIDI*)mididata[i].dat;
9309
9310
2/2
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 11 times.
2783 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9311 2772 tunes[ZC_MIDI_COUNT+j].data=NULL;
9312
9313 11 master_volume(digi_volume,midi_volume);
9314 11 }
9315
9316 // returns number of voices currently allocated
9317 int32_t sfx_count()
9318 {
9319 int32_t c=0;
9320
9321 for(int32_t i=0; i<WAV_COUNT; i++)
9322 if(sfx_voice[i]!=-1)
9323 ++c;
9324
9325 return c;
9326 }
9327
9328 // clean up finished samples
9329 3132 void sfx_cleanup()
9330 {
9331
2/2
✓ Branch 0 taken 801792 times.
✓ Branch 1 taken 3132 times.
804924 for(int32_t i=0; i<WAV_COUNT; i++)
9332
4/4
✓ Branch 0 taken 5007 times.
✓ Branch 1 taken 796785 times.
✓ Branch 2 taken 5003 times.
✓ Branch 3 taken 4 times.
801796 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9333 {
9334 4 deallocate_voice(sfx_voice[i]);
9335 4 sfx_voice[i]=-1;
9336 4 }
9337 3132 }
9338
9339 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9340 // if a voice is already allocated (and/or playing), then it just returns true
9341 // Returns true: voice is allocated
9342 // false: unsuccessful
9343 106 bool sfx_init(int32_t index)
9344 {
9345 // check index
9346
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
106 if(index<=0 || index>=WAV_COUNT)
9347 18 return false;
9348
9349
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 24 times.
88 if(sfx_voice[index]==-1)
9350 {
9351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(sfxdat)
9352 {
9353 if(index<Z35)
9354 {
9355 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9356 }
9357 else
9358 {
9359 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9360 }
9361 }
9362 else
9363 {
9364 24 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9365 }
9366
9367 24 voice_set_volume(sfx_voice[index], sfx_volume);
9368 24 }
9369
9370 88 return sfx_voice[index] != -1;
9371 106 }
9372
9373 // plays an sfx sample
9374 96 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9375 {
9376
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
96 if(!sfx_init(index))
9377 8 return;
9378
9379 88 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9380 88 voice_set_pan(sfx_voice[index],pan);
9381
9382 88 int32_t pos = voice_get_position(sfx_voice[index]);
9383
9384
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(restart) voice_set_position(sfx_voice[index],0);
9385
9386
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 33 times.
88 if(pos<=0)
9387 55 voice_start(sfx_voice[index]);
9388 96 }
9389
9390 // true if sfx is allocated
9391 bool sfx_allocated(int32_t index)
9392 {
9393 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9394 }
9395
9396 // start it (in loop mode) if it's not already playing,
9397 // otherwise adjust it to play in loop mode -DD
9398 10 void cont_sfx(int32_t index)
9399 {
9400
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!sfx_init(index))
9401 {
9402 10 return;
9403 }
9404
9405 if(voice_get_position(sfx_voice[index])<=0)
9406 {
9407 voice_set_position(sfx_voice[index],0);
9408 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9409 voice_start(sfx_voice[index]);
9410 }
9411 else
9412 {
9413 adjust_sfx(index, 128, true);
9414 }
9415 10 }
9416
9417 // adjust parameters while playing
9418 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9419 {
9420 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9421 return;
9422
9423 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9424 voice_set_pan(sfx_voice[index],pan);
9425 }
9426
9427 // pauses a voice
9428 void pause_sfx(int32_t index)
9429 {
9430 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9431 voice_stop(sfx_voice[index]);
9432 }
9433
9434 // resumes a voice
9435 void resume_sfx(int32_t index)
9436 {
9437 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9438 voice_start(sfx_voice[index]);
9439 }
9440
9441 // pauses all active voices
9442 void pause_all_sfx()
9443 {
9444 for(int32_t i=0; i<WAV_COUNT; i++)
9445 if(sfx_voice[i]!=-1)
9446 voice_stop(sfx_voice[i]);
9447 }
9448
9449 // resumes all paused voices
9450 void resume_all_sfx()
9451 {
9452 for(int32_t i=0; i<WAV_COUNT; i++)
9453 if(sfx_voice[i]!=-1)
9454 voice_start(sfx_voice[i]);
9455 }
9456
9457 // stops an sfx and deallocates the voice
9458 1915 void stop_sfx(int32_t index)
9459 {
9460
2/4
✓ Branch 0 taken 1915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1915 times.
✗ Branch 3 not taken.
1915 if(index<=0 || index>=WAV_COUNT)
9461 return;
9462
9463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1915 times.
1915 if(sfx_voice[index]!=-1)
9464 {
9465 deallocate_voice(sfx_voice[index]);
9466 sfx_voice[index]=-1;
9467 }
9468 1915 }
9469
9470 // Stops SFX played by Hero's item of the given family
9471 2 void stop_item_sfx(int32_t family)
9472 {
9473 2 int32_t id=current_item_id(family);
9474
9475
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(id<0)
9476 2 return;
9477
9478 stop_sfx(itemsbuf[id].usesound);
9479 2 }
9480
9481 10 void kill_sfx()
9482 {
9483
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<WAV_COUNT; i++)
9484
2/2
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 20 times.
2580 if(sfx_voice[i]!=-1)
9485 {
9486 20 deallocate_voice(sfx_voice[i]);
9487 20 sfx_voice[i]=-1;
9488 20 }
9489 10 }
9490
9491 53 int32_t pan(int32_t x)
9492 {
9493
1/4
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 switch(pan_style)
9494 {
9495 case 0:
9496 return 128;
9497
9498 case 1:
9499 53 return vbound((x>>1)+68,0,255);
9500
9501 case 2:
9502 return vbound(((x*3)>>2)+36,0,255);
9503 }
9504
9505 return vbound(x,0,255);
9506 53 }
9507
9508 /*******************************/
9509 /******* Input Handlers ********/
9510 /*******************************/
9511
9512 15536 bool joybtn(int32_t b)
9513 {
9514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15536 times.
15536 if(b == 0)
9515 return false;
9516
9517 15536 return joy[joystick_index].button[b-1].b !=0;
9518 15536 }
9519
9520 const char* joybtn_name(int32_t b)
9521 {
9522 if(b == 0)
9523 return "";
9524
9525 return joy[joystick_index].button[b-1].name;
9526 }
9527
9528 int32_t next_press_key()
9529 {
9530 return readkey()>>8;
9531 }
9532
9533 int32_t next_press_btn()
9534 {
9535 clear_keybuf();
9536 /*bool b[joy[joystick_index].num_buttons+1];
9537
9538 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9539 b[i]=joybtn(i);*/
9540
9541 //first, we need to wait until they're pressing no buttons
9542 for(;;)
9543 {
9544 if(keypressed())
9545 {
9546 switch(readkey()>>8)
9547 {
9548 case KEY_ESC:
9549 return -1;
9550
9551 case KEY_SPACE:
9552 return 0;
9553 }
9554 }
9555
9556 poll_joystick();
9557 bool done = true;
9558
9559 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9560 {
9561 if(joybtn(i)) done = false;
9562 }
9563
9564 if(done) break;
9565 rest(1);
9566 }
9567
9568 //now, we need to wait for them to press any button
9569 for(;;)
9570 {
9571 if(keypressed())
9572 {
9573 switch(readkey()>>8)
9574 {
9575 case KEY_ESC:
9576 return -1;
9577
9578 case KEY_SPACE:
9579 return 0;
9580 }
9581 }
9582
9583 poll_joystick();
9584
9585 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9586 {
9587 if(joybtn(i)) return i;
9588 }
9589 rest(1);
9590 }
9591 }
9592
9593 static bool rButton(bool(proc)(),bool &flag)
9594 {
9595 if(!proc())
9596 {
9597 flag=false;
9598 }
9599 else if(!flag)
9600 {
9601 flag=true;
9602 return true;
9603 }
9604
9605 return false;
9606 }
9607
9608 56424 static bool rButton(bool &btn, bool &flag)
9609 {
9610
2/2
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 54726 times.
56424 if(!btn)
9611 {
9612 54726 flag=false;
9613 54726 }
9614
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 1608 times.
1698 else if(!flag)
9615 {
9616 90 flag=true;
9617 90 return true;
9618 }
9619
9620 56334 return false;
9621 56424 }
9622 static bool rButtonPeek(bool btn, bool flag)
9623 {
9624 if(!btn)
9625 {
9626 return false;
9627 }
9628 else if(!flag)
9629 {
9630 return true;
9631 }
9632
9633 return false;
9634 }
9635
9636 // Updated only by keyboard/gamepad.
9637 // If in replay mode, this is set directly by the replay system.
9638 // This should never be read from directly - use control_state instead.
9639 bool raw_control_state[ZC_CONTROL_STATES]=
9640 {
9641 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9642 };
9643
9644 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9645 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9646 // lasts until the next call to load_control_state.
9647 bool control_state[ZC_CONTROL_STATES]=
9648 {
9649 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9650 };
9651
9652 bool disable_control[ZC_CONTROL_STATES]=
9653 {
9654 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9655 };
9656
9657 bool drunk_toggle_state[11]=
9658 {
9659 false, false, false, false, false, false, false, false, false, false, false
9660 };
9661
9662 bool disabledKeys[127]=
9663 {
9664 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9665 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9666 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9667 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9668 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9669 false,false,false,false,false,false,false
9670 };
9671
9672 bool KeyInput[127]=
9673 {
9674 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9675 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9676 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9677 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9678 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9679 false,false,false,false,false,false,false
9680 };
9681
9682 bool KeyPress[127]=
9683 {
9684 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9685 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9686 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9687 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9688 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9689 false,false,false,false,false,false,false
9690 };
9691
9692 bool key_current_frame[127];
9693 bool key_previous_frame[127];
9694
9695 static bool key_system[127];
9696 static bool key_system_previous[127];
9697 static bool key_system_press[127];
9698
9699 bool button_press[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9700 bool button_hold[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9701
9702 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9703 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9704 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9705 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9706 #define STICK_PRECISION 56 //define your own sensitivity
9707
9708 2343 void load_control_state()
9709 {
9710
1/2
✓ Branch 0 taken 2343 times.
✗ Branch 1 not taken.
2343 if (!replay_is_replaying())
9711 {
9712 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9713 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9714 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9715 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9716 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9717 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9718 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9719 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9720 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9721 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9722 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9723 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9724 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9725 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9726
9727 if(num_joysticks != 0)
9728 {
9729 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9730 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9731 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9732 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9733 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9734 }
9735 else
9736 {
9737 raw_control_state[14] = false;
9738 raw_control_state[15] = false;
9739 raw_control_state[16] = false;
9740 raw_control_state[17] = false;
9741 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9742 }
9743 }
9744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2343 times.
2343 if (replay_is_active())
9745 {
9746
1/2
✓ Branch 0 taken 2343 times.
✗ Branch 1 not taken.
2343 if (replay_get_version() < 3)
9747 2343 replay_poll();
9748 else if (replay_is_replaying() && replay_get_version() < 6)
9749 replay_peek_input();
9750 2343 }
9751
9752 // Some test replay files were made before a serious input bug was fixed, so instead
9753 // of re-doing them or tossing them out, just check for that zplay version.
9754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2343 times.
2343 bool botched_input = replay_is_replaying() && replay_get_version() == 1;
9755
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 42174 times.
44517 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9756 {
9757 42174 control_state[i] = raw_control_state[i];
9758
3/4
✓ Branch 0 taken 42174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1633 times.
✓ Branch 3 taken 40541 times.
42174 if(!botched_input && !control_state[i])
9759 40541 down_control_states[i] = false;
9760 42174 }
9761
9762 2343 button_press[0]=rButton(control_state[0],button_hold[0]);
9763 2343 button_press[1]=rButton(control_state[1],button_hold[1]);
9764 2343 button_press[2]=rButton(control_state[2],button_hold[2]);
9765 2343 button_press[3]=rButton(control_state[3],button_hold[3]);
9766 2343 button_press[4]=rButton(control_state[4],button_hold[4]);
9767 2343 button_press[5]=rButton(control_state[5],button_hold[5]);
9768 2343 button_press[6]=rButton(control_state[6],button_hold[6]);
9769 2343 button_press[7]=rButton(control_state[7],button_hold[7]);
9770 2343 button_press[8]=rButton(control_state[8],button_hold[8]);
9771 2343 button_press[9]=rButton(control_state[9],button_hold[9]);
9772 2343 button_press[10]=rButton(control_state[10],button_hold[10]);
9773 2343 button_press[11]=rButton(control_state[11],button_hold[11]);
9774 2343 button_press[12]=rButton(control_state[12],button_hold[12]);
9775 2343 button_press[13]=rButton(control_state[13],button_hold[13]);
9776 2343 button_press[14]=rButton(control_state[14],button_hold[14]);
9777 2343 button_press[15]=rButton(control_state[15],button_hold[15]);
9778 2343 button_press[16]=rButton(control_state[16],button_hold[16]);
9779 2343 button_press[17]=rButton(control_state[17],button_hold[17]);
9780 2343 }
9781
9782 // Returns true if any game key is pressed. This is needed because keypressed()
9783 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9784 18008 bool zc_key_pressed()
9785 //may also need to use zc_getrawkey
9786 {
9787
7/10
✓ Branch 0 taken 15198 times.
✓ Branch 1 taken 2810 times.
✓ Branch 2 taken 2810 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2810 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2519 times.
✓ Branch 7 taken 2519 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1546 times.
19554 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9788
4/6
✓ Branch 0 taken 2519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2181 times.
✓ Branch 5 taken 2181 times.
2519 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9789
4/6
✓ Branch 0 taken 2181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1666 times.
✓ Branch 5 taken 1666 times.
2181 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9790
4/6
✓ Branch 0 taken 1666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1666 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1584 times.
✓ Branch 5 taken 1584 times.
1666 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9791
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9792
2/4
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1584 times.
✗ Branch 3 not taken.
1584 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9793
3/4
✓ Branch 0 taken 1546 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
1584 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9794
2/4
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
1546 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9795
2/4
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
1546 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9796
2/4
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
1546 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9797
2/4
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
1546 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9798
2/4
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
1546 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9799
2/4
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✗ Branch 3 not taken.
1546 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9800
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9801 32362 return true;
9802
9803 1546 return false;
9804 3512 }
9805
9806 31741 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9807 {
9808 31741 bool ret = false, drunkstate = false;
9809 31741 bool* flag = &down_control_states[btn];
9810
2/7
✓ Branch 0 taken 28226 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3515 times.
31741 switch(btn)
9811 {
9812 case btnF12:
9813 ret = zc_getkey(KEY_F12, ignoreDisable);
9814 eatEntirely = false;
9815 break;
9816 case btnF11:
9817 ret = zc_getkey(KEY_F11, ignoreDisable);
9818 eatEntirely = false;
9819 break;
9820 case btnF5:
9821 ret = zc_getkey(KEY_F5, ignoreDisable);
9822 eatEntirely = false;
9823 break;
9824 case btnQ:
9825 ret = zc_getkey(KEY_Q, ignoreDisable);
9826 eatEntirely = false;
9827 break;
9828 case btnI:
9829 ret = zc_getkey(KEY_I, ignoreDisable);
9830 eatEntirely = false;
9831 break;
9832 case btnM:
9833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3515 times.
3515 if(FFCore.kb_typing_mode) return false;
9834 3515 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9835 3515 eatEntirely = false;
9836 3515 break;
9837 default: //control_state[] index
9838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28226 times.
28226 if(FFCore.kb_typing_mode) return false;
9839
3/6
✓ Branch 0 taken 27615 times.
✓ Branch 1 taken 611 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27615 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28226 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9840
2/2
✓ Branch 0 taken 1897 times.
✓ Branch 1 taken 26329 times.
28226 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9841
4/4
✓ Branch 0 taken 26104 times.
✓ Branch 1 taken 2122 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 2074 times.
30348 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9842 28226 }
9843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31741 times.
31741 assert(flag);
9844
2/2
✓ Branch 0 taken 17491 times.
✓ Branch 1 taken 14250 times.
31741 if(press)
9845 {
9846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14250 times.
14250 if(peek)
9847 ret = rButtonPeek(ret, *flag);
9848 14250 else ret = rButton(ret, *flag);
9849 14250 }
9850
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31741 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31741 if(eatEntirely && ret) control_state[btn] = false;
9851
3/4
✓ Branch 0 taken 21542 times.
✓ Branch 1 taken 10199 times.
✓ Branch 2 taken 21542 times.
✗ Branch 3 not taken.
31741 if(drunk && drunkstate) ret = !ret;
9852 31741 return ret;
9853 31741 }
9854
9855 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9856 {
9857 byte ret = 0;
9858 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9859 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9860 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9861 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9862 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9863 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9864 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9865 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9866 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9867 }
9868
9869 byte checkIntBtnVal(byte intbtn, byte vals)
9870 {
9871 return intbtn&vals;
9872 }
9873
9874 285 bool Up()
9875 {
9876 285 return getInput(btnUp);
9877 }
9878 bool Down()
9879 {
9880 return getInput(btnDown);
9881 }
9882 bool Left()
9883 {
9884 return getInput(btnLeft);
9885 }
9886 bool Right()
9887 {
9888 return getInput(btnRight);
9889 }
9890 185 bool cAbtn()
9891 {
9892 185 return getInput(btnA);
9893 }
9894 222 bool cBbtn()
9895 {
9896 222 return getInput(btnB);
9897 }
9898 bool cSbtn()
9899 {
9900 return getInput(btnS);
9901 }
9902 bool cLbtn()
9903 {
9904 return getInput(btnL);
9905 }
9906 bool cRbtn()
9907 {
9908 return getInput(btnR);
9909 }
9910 bool cPbtn()
9911 {
9912 return getInput(btnP);
9913 }
9914 bool cEx1btn()
9915 {
9916 return getInput(btnEx1);
9917 }
9918 bool cEx2btn()
9919 {
9920 return getInput(btnEx2);
9921 }
9922 bool cEx3btn()
9923 {
9924 return getInput(btnEx3);
9925 }
9926 bool cEx4btn()
9927 {
9928 return getInput(btnEx4);
9929 }
9930 bool AxisUp()
9931 {
9932 return getInput(btnAxisUp);
9933 }
9934 bool AxisDown()
9935 {
9936 return getInput(btnAxisDown);
9937 }
9938 bool AxisLeft()
9939 {
9940 return getInput(btnAxisLeft);
9941 }
9942 bool AxisRight()
9943 {
9944 return getInput(btnAxisRight);
9945 }
9946
9947 bool cMbtn()
9948 {
9949 return getInput(btnM);
9950 }
9951 bool cF12()
9952 {
9953 return getInput(btnF12);
9954 }
9955 bool cF11()
9956 {
9957 return getInput(btnF11);
9958 }
9959 bool cF5()
9960 {
9961 return getInput(btnF5);
9962 }
9963 bool cQ()
9964 {
9965 return getInput(btnQ);
9966 }
9967 bool cI()
9968 {
9969 return getInput(btnI);
9970 }
9971
9972 bool rUp()
9973 {
9974 return getInput(btnUp, true);
9975 }
9976 bool rDown()
9977 {
9978 return getInput(btnDown, true);
9979 }
9980 bool rLeft()
9981 {
9982 return getInput(btnLeft, true);
9983 }
9984 bool rRight()
9985 {
9986 return getInput(btnRight, true);
9987 }
9988 1 bool rAbtn()
9989 {
9990 1 return getInput(btnA, true);
9991 }
9992 1 bool rBbtn()
9993 {
9994 1 return getInput(btnB, true);
9995 }
9996 1888 bool rSbtn()
9997 {
9998 1888 return getInput(btnS, true);
9999 }
10000 3512 bool rMbtn()
10001 {
10002 3512 return getInput(btnM, true);
10003 }
10004 bool rLbtn()
10005 {
10006 return getInput(btnL, true);
10007 }
10008 bool rRbtn()
10009 {
10010 return getInput(btnR, true);
10011 }
10012 1888 bool rPbtn()
10013 {
10014 1888 return getInput(btnP, true);
10015 }
10016 bool rEx1btn()
10017 {
10018 return getInput(btnEx1, true);
10019 }
10020 bool rEx2btn()
10021 {
10022 return getInput(btnEx2, true);
10023 }
10024 bool rEx3btn()
10025 {
10026 return getInput(btnEx3, true);
10027 }
10028 bool rEx4btn()
10029 {
10030 return getInput(btnEx4, true);
10031 }
10032 bool rAxisUp()
10033 {
10034 return getInput(btnAxisUp, true);
10035 }
10036 bool rAxisDown()
10037 {
10038 return getInput(btnAxisDown, true);
10039 }
10040 bool rAxisLeft()
10041 {
10042 return getInput(btnAxisLeft, true);
10043 }
10044 bool rAxisRight()
10045 {
10046 return getInput(btnAxisRight, true);
10047 }
10048
10049 bool rF11()
10050 {
10051 return getInput(btnF11, true);
10052 }
10053 bool rQ()
10054 {
10055 return getInput(btnQ, true);
10056 }
10057 bool rI()
10058 {
10059 return getInput(btnI, true);
10060 }
10061
10062 2997 bool DrunkUp()
10063 {
10064 2997 return getInput(btnUp, false, true);
10065 }
10066 2660 bool DrunkDown()
10067 {
10068 2660 return getInput(btnDown, false, true);
10069 }
10070 1012 bool DrunkLeft()
10071 {
10072 1012 return getInput(btnLeft, false, true);
10073 }
10074 737 bool DrunkRight()
10075 {
10076 737 return getInput(btnRight, false, true);
10077 }
10078 2126 bool DrunkcAbtn()
10079 {
10080 2126 return getInput(btnA, false, true);
10081 }
10082 1888 bool DrunkcBbtn()
10083 {
10084 1888 return getInput(btnB, false, true);
10085 }
10086 1888 bool DrunkcEx1btn()
10087 {
10088 1888 return getInput(btnEx1, false, true);
10089 }
10090 1888 bool DrunkcEx2btn()
10091 {
10092 1888 return getInput(btnEx2, false, true);
10093 }
10094 bool DrunkcSbtn()
10095 {
10096 return getInput(btnS, false, true);
10097 }
10098 bool DrunkcMbtn()
10099 {
10100 return getInput(btnM, false, true);
10101 }
10102 bool DrunkcLbtn()
10103 {
10104 return getInput(btnL, false, true);
10105 }
10106 bool DrunkcRbtn()
10107 {
10108 return getInput(btnR, false, true);
10109 }
10110 bool DrunkcPbtn()
10111 {
10112 return getInput(btnP, false, true);
10113 }
10114
10115 bool DrunkrUp()
10116 {
10117 return getInput(btnUp, true, true);
10118 }
10119 bool DrunkrDown()
10120 {
10121 return getInput(btnDown, true, true);
10122 }
10123 bool DrunkrLeft()
10124 {
10125 return getInput(btnLeft, true, true);
10126 }
10127 bool DrunkrRight()
10128 {
10129 return getInput(btnRight, true, true);
10130 }
10131 1285 bool DrunkrAbtn()
10132 {
10133 1285 return getInput(btnA, true, true);
10134 }
10135 1285 bool DrunkrBbtn()
10136 {
10137 1285 return getInput(btnB, true, true);
10138 }
10139 bool DrunkrEx1btn()
10140 {
10141 return getInput(btnEx1, true, true);
10142 }
10143 bool DrunkrEx2btn()
10144 {
10145 return getInput(btnEx2, true, true);
10146 }
10147 bool DrunkrEx3btn()
10148 {
10149 return getInput(btnEx3, true, true);
10150 }
10151 bool DrunkrEx4btn()
10152 {
10153 return getInput(btnEx4, true, true);
10154 }
10155 bool DrunkrSbtn()
10156 {
10157 return getInput(btnS, true, true);
10158 }
10159 bool DrunkrMbtn()
10160 {
10161 return getInput(btnM, true, true);
10162 }
10163 1888 bool DrunkrLbtn()
10164 {
10165 1888 return getInput(btnL, true, true);
10166 }
10167 1888 bool DrunkrRbtn()
10168 {
10169 1888 return getInput(btnR, true, true);
10170 }
10171 bool DrunkrPbtn()
10172 {
10173 return getInput(btnP, true, true);
10174 }
10175
10176 3 void eat_buttons()
10177 {
10178 3 getInput(btnA, true, false, true);
10179 3 getInput(btnB, true, false, true);
10180 3 getInput(btnS, true, false, true);
10181 3 getInput(btnM, true, false, true);
10182 3 getInput(btnL, true, false, true);
10183 3 getInput(btnR, true, false, true);
10184 3 getInput(btnP, true, false, true);
10185 3 getInput(btnEx1, true, false, true);
10186 3 getInput(btnEx2, true, false, true);
10187 3 getInput(btnEx3, true, false, true);
10188 3 getInput(btnEx4, true, false, true);
10189 3 }
10190
10191 // Is true for the _first frame_ of a key press.
10192 // But! it is possible that a script manually sets the value of KeyPress,
10193 // in which case it will be restored to the "true" value based on `key_current_frame`
10194 // and `key_previous_frame` on the next frame.
10195 bool zc_readkey(int32_t k, bool ignoreDisable)
10196 {
10197 if(ignoreDisable) return KeyPress[k];
10198 switch(k)
10199 {
10200 case KEY_F7:
10201 case KEY_F8:
10202 case KEY_F9:
10203 return KeyPress[k];
10204
10205 default:
10206 return KeyPress[k] && !disabledKeys[k];
10207 }
10208 }
10209
10210 // Is true for _every frame_ a key is held down.
10211 // But! it is possible that a script manually sets the value of KeyInput,
10212 // in which case it will be restored to the "true" value based on `key_current_frame`
10213 // on the next frame.
10214 bool zc_getkey(int32_t k, bool ignoreDisable)
10215 {
10216 if(ignoreDisable) return KeyInput[k];
10217 switch(k)
10218 {
10219 case KEY_F7:
10220 case KEY_F8:
10221 case KEY_F9:
10222 return KeyInput[k];
10223
10224 default:
10225 return KeyInput[k] && !disabledKeys[k];
10226 }
10227 }
10228
10229 // Reads (and then clears) the current frame key state directly.
10230 // Scripts can also modify `key_current_frame`.
10231 bool zc_readrawkey(int32_t k, bool ignoreDisable)
10232 {
10233 if(zc_getrawkey(k, ignoreDisable))
10234 {
10235 _key[k]=key[k]=key_current_frame[k]=0;
10236 return true;
10237 }
10238 _key[k]=key[k]=key_current_frame[k]=0;
10239 return false;
10240 }
10241
10242 // Reads the current frame key state directly.
10243 // Scripts can also modify `key_current_frame`.
10244 30193 bool zc_getrawkey(int32_t k, bool ignoreDisable)
10245 {
10246
2/2
✓ Branch 0 taken 26681 times.
✓ Branch 1 taken 3512 times.
30193 if(ignoreDisable) return key_current_frame[k];
10247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
3512 switch(k)
10248 {
10249 case KEY_F7:
10250 case KEY_F8:
10251 case KEY_F9:
10252 return key_current_frame[k];
10253
10254 default:
10255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3512 times.
3512 return key_current_frame[k] && !disabledKeys[k];
10256 }
10257 30193 }
10258
10259 // Only used for a handful of keys, like tilde and Function keys.
10260 // This state is never read within the game.
10261 // It exists so that all keyboard input still functions during replay,
10262 // without inadvertently doing things like toggling throttling if the player
10263 // presses ~
10264 3132 bool zc_get_system_key(int32_t k)
10265 {
10266 3132 return key_system[k];
10267 }
10268
10269 // True for the _first_ frame of a key press.
10270 38632 bool zc_read_system_key(int32_t k)
10271 {
10272 38632 return key_system_press[k];
10273 }
10274
10275 446024 bool is_system_key(int32_t k)
10276 {
10277
2/2
✓ Branch 0 taken 414416 times.
✓ Branch 1 taken 31608 times.
446024 switch (k)
10278 {
10279 case KEY_BACKQUOTE:
10280 case KEY_CLOSEBRACE:
10281 case KEY_END:
10282 case KEY_HOME:
10283 case KEY_OPENBRACE:
10284 case KEY_PGDN:
10285 case KEY_PGUP:
10286 case KEY_TAB:
10287 case KEY_TILDE:
10288 31608 return true;
10289 }
10290 414416 return is_Fkey(k);
10291 446024 }
10292
10293 3512 void update_system_keys()
10294 {
10295 3512 poll_keyboard();
10296
2/2
✓ Branch 0 taken 446024 times.
✓ Branch 1 taken 3512 times.
449536 for (int32_t q = 0; q < 127; ++q)
10297 {
10298
2/2
✓ Branch 0 taken 73752 times.
✓ Branch 1 taken 372272 times.
446024 if (!is_system_key(q))
10299 372272 continue;
10300
10301 73752 key_system[q] = key[q];
10302
1/2
✓ Branch 0 taken 73752 times.
✗ Branch 1 not taken.
73752 key_system_press[q] = key_system[q] && !key_system_previous[q];
10303 73752 key_system_previous[q] = key_system[q];
10304 73752 }
10305 3512 }
10306
10307 3132 void update_keys()
10308 {
10309
1/2
✓ Branch 0 taken 3132 times.
✗ Branch 1 not taken.
3132 if (!replay_is_replaying())
10310 poll_keyboard();
10311
10312
2/2
✓ Branch 0 taken 3132 times.
✓ Branch 1 taken 397764 times.
400896 for (int32_t q = 0; q < 127; ++q)
10313 {
10314 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10315
1/2
✓ Branch 0 taken 397764 times.
✗ Branch 1 not taken.
397764 if (!replay_is_replaying())
10316 key_current_frame[q] = key[q];
10317
10318
2/2
✓ Branch 0 taken 395744 times.
✓ Branch 1 taken 2020 times.
397764 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10319
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 397700 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
397764 if (KeyPress[q] && q == KEY_B) {
10320 int lol = 1;
10321 }
10322 397764 KeyInput[q] = key_current_frame[q];
10323 397764 key_previous_frame[q] = key_current_frame[q];
10324 397764 }
10325 3132 }
10326
10327 bool zc_disablekey(int32_t k, bool val)
10328 {
10329 switch(k)
10330 {
10331 case KEY_F7:
10332 case KEY_F8:
10333 case KEY_F9:
10334 return false;
10335
10336 default:
10337 disabledKeys[k] = val;
10338 return true;
10339 }
10340 }
10341
10342 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10343 {
10344 timer=timer;
10345 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10346 }
10347
10348 // these are here so that copy_dialog won't choke when compiling zelda
10349 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10350 {
10351 return D_O_K;
10352 }
10353
10354 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10355 {
10356 return D_O_K;
10357 }
10358
10359 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10360 {
10361 return D_O_K;
10362 }
10363
10364 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10365 {
10366 return D_O_K;
10367 }
10368
10369 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10370 {
10371 return D_O_K;
10372 }
10373
10374 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10375 {
10376 return D_O_K;
10377 }
10378
10379 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10380 {
10381 return D_O_K;
10382 }
10383
10384 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10385 {
10386 return D_O_K;
10387 }
10388
10389 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10390 {
10391 return D_O_K;
10392 }
10393
10394 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10395 {
10396 return D_O_K;
10397 }
10398
10399 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10400 {
10401 return D_O_K;
10402 }
10403
10404 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10405 {
10406 return D_O_K;
10407 }
10408
10409 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10410 {
10411 return D_O_K;
10412 }
10413
10414 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10415 {
10416 return D_O_K;
10417 }
10418
10419 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10420 {
10421 return D_O_K;
10422 }
10423
10424 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10425 {
10426 return D_O_K;
10427 }
10428
10429 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10430 {
10431 return D_O_K;
10432 }
10433
10434 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10435 {
10436 return D_O_K;
10437 }
10438
10439 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10440 {
10441 return D_O_K;
10442 }
10443
10444 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10445 {
10446 return D_O_K;
10447 }
10448
10449 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10450 {
10451 return D_O_K;
10452 }
10453
10454 /*** end of zc_sys.cc ***/
10455
10456